ISO8601 year week formatting

Hello All

This seems like it should be a very common situation, but I cannot seem to find a standard function in Dates to return the ISO 8601 Year and Week in Julia? The week number is correct, but It doesn’t seem to return the correct year.

in SQL, the date format would be ‘IYYY-IW’ which would return 2025-01 for Dec 31, 2024.

Is there a formatting code that I am missing from the documentation for the ISO8601 Year?

2 Likes

you could just use the standard ‘2001-08-12’ with no special syntax needed and avoid the problem altogether. ISO-8601 or it’s invalid.

That doesn’t look like it prints the week number, though..

This seems like an omission in the Dates module. The ISO 8601 specifier for week number appears to be Www, but this is not supported by Dates.

There is a week function, so you can do Dates.week(now()), which does indeed return the ISO 8601 week number, but no built-in format string. You can write a custom function based on this, though.

1 Like

Okay.., now I got it. Thanks for clarify.