We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Datepart with weeknumber ("ww") on year 2021 shows wrong week number.RSS

3 replies

Last post Jan 26, 2021 08:40 AM by samwu

  • Datepart with weeknumber ("ww") on year 2021 shows wrong week number.

    Jan 25, 2021 07:54 AM|SantinoDev|LINK

    Today is 25th January (week 4), and I'm using this function in ASP classic:

    <%=DatePart("ww", Date)%>

    The result becomes 5. But today is week number 4. I tried to hardcode the string instead of Date - function like this:

    <%=DatePart("ww", "2021-01-25")%>

    Still getting 5 as result. Are there any workarounds for this issue?

  • Re: Datepart with weeknumber ("ww") on year 2021 shows wrong week number.

    Jan 25, 2021 09:52 AM|samwu|LINK

    Hi SantinoDev,

    SantinoDev

    Today is 25th January (week 4), and I'm using this function in ASP classic:

    <%=DatePart("ww", Date)%>

    The result becomes 5. But today is week number 4. I tried to hardcode the string instead of Date - function like this:

    <%=DatePart("ww", "2021-01-25")%>

    Still getting 5 as result. Are there any workarounds for this issue?

    This is based on when you started the first week, in the classic asp, at least 1 day after the start date of the first week is required to be counted as a week, so the result is 5. you can refer to the Week Number Calculator below:

    Week Number Calculator1

    Week Number Calculator2

    Best regards,

    Sam

    IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
  • Re: Datepart with weeknumber ("ww") on year 2021 shows wrong week number.

    Jan 25, 2021 10:06 AM|SantinoDev|LINK

    Hi samwu,

    I understand. So what we are using according to the second link is "ISO 8601 week date system". Is it possible to switch it over to that week date system in ASP classic?

    Best regards,

    SantinoDev

  • Re: Datepart with weeknumber ("ww") on year 2021 shows wrong week number.

    Jan 26, 2021 08:40 AM|samwu|LINK

    Hi SantinoDev,

    SantinoDev

    I understand. So what we are using according to the second link is "ISO 8601 week date system". Is it possible to switch it over to that week date system in ASP classic?

    It is impossible to specify week date system in ASP classic, but you can try some methods to get the weeknumber you want. you can use the following link as a reference:

    https://stackoverflow.com/questions/32666335/display-dates-based-on-week-number-asp-classic

    Best regards,

    Sam

    IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >