Issue
The formatDateTime(date, 'w') function returns unexpected week numbers around the change of the year. Dates at both the end and beginning of a year can be assigned to week fifty-three instead of week one.
For example, both formatDateTime(2025-12-29, 'w') and formatDateTime(2026-01-01, 'w') return fifty-three of 2025, although it is expected to be week one of 2026.
Environment
Studio Pro (all versions)
Cause
The week number returned by formatDateTime(date, 'w') is determined by the application language and Date and Time runtime settings. Mendix relies on Java date formatting, where the week in year calculation is locale-dependent.
When the selected language does not follow ISO 8601 week numbering, dates around the start or end of a year can be assigned to week fifty-three instead of week one. Changing the runtime settings or language to one that aligns with ISO 8601 results in different week number calculations.
For example:
- The en_US (English, United States) locale does not follow the ISO 8601 standard for week numbering.
- However, the en_GB (English, United Kingdom) locale does align with the ISO 8601 standard.
Solution / Workaround
To ensure ISO 8601–compliant week numbering when using formatDateTime(date, 'w'), adjust the application default language and runtime settings so that they align with ISO 8601 behavior.
Internal information related
- 266615, 261893
- RUN-4219
- C3T260XGA/p1724343965920349, C3T260XGA/p1760425734340249
Additional information
Other documentation: Week of year and Week year
0 Comments