locked
Datepart with weeknumber ("ww") on year 2021 shows wrong week number. RRS feed

  • Question

  • User154948892 posted

    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?

    Monday, January 25, 2021 7:54 AM

All replies

  • User1065476709 posted

    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

    Monday, January 25, 2021 9:52 AM
  • User154948892 posted

    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

    Monday, January 25, 2021 10:06 AM
  • User1065476709 posted

    Hi 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

    Tuesday, January 26, 2021 8:40 AM