• Resolved Nathan

    (@natedanielz)


    Hi,

    Again, like in this thread, the week numbers are wrong. Can you please update the plugin or tell me what to do?

    Thanks,
    Nathan

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author CodePeople2

    (@codepeople2)

    Hello @natedanielz

    What values are you entering for testing the WEEKNUM operation? I selected some dates through the fieldname33 and the WEEKNUM returns the correct result. However, you should include a conditional operation in the equation to ensure the field is not empty before calling the operation:

    IF(fieldname33, WEEKNUM(fieldname33), '')

    Best regards.

    Thread Starter Nathan

    (@natedanielz)

    Apologies, totally forgot to say it happens in the year 2025. There are 52 weeks in 2024.
    Week 1 2025 start on the 30th of December, but your calendar sees 6 January as the first week.

    I just have a simple rule: WEEKNUM(fieldname33);

    This has always worked. I think that’s not the problem right? I think the calendar is calculating 53 weeks in 2024

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @natedanielz

    This is not an error, it is an interpretation of the data. Our plugin calculates in which 7-day interval the date falls. In a leap year like 2024, December 30th would be the 365th day. 365/7=52.14…, therefore the date December 30th would fall in the 53rd 7-day interval still belonging to the 2024 year.

    However, if you want force the year to 52 weeks and considering any date belonging to the 53 week to the next year, you can edit the equation as follows:

    IF(fieldname33, WEEKNUM(fieldname33)%52, '')

    or using the REMAINDER operation:

    IF(fieldname33, REMAINDER(WEEKNUM(fieldname33),52), '')

    Best regards.

    Thread Starter Nathan

    (@natedanielz)

    Thanks, your operation works for this year, but not for next year.

    You can check the official week numbers:
    Netherlands: https://www.timeanddate.com/calendar/?year=2025&country=25&wno=1
    US: https://www.timeanddate.com/calendar/?year=2025&country=1&wno=1
    India: https://www.timeanddate.com/calendar/?year=2025&country=35&wno=1

    So what to do?

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @natedanielz

    If you want to considering the weeks instead of seven days intervals, but intervals from Sunday to Saturday, please edit the equation as follows:


    (function () {
    let d = fieldname33;
    if ( ! d) return '';
    let f = DATEOBJ('01/01/' + YEAR(d), 'dd/mm/yyyy');
    return REMAINDER(CEIL((DATEDIFF(d, f, 'dd/mm/yyyy', 'd')['days'] + WEEKDAY(f)) / 7), 52);
    })()

    Best regards.

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @natedanielz

    We released at this moment a new plugin update that includes the WEEKNUM2 operation, it unlike WEEKNUM takes into consideration the day of the week. So, you could implement the equation as follows:

    IF(fieldname33, WEEKNUM2(fieldname33), '');

    Best regards.

    Thread Starter Nathan

    (@natedanielz)

    Ah perfect, that’s better than using the function correct? Because the function probably needs to be changed every for year?

    Anyway, thanks for the rapid support AND update of the plugin as well. Spot on!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.