
yearweek
I have been using yearweek to find the week number of the current date, and for a time period in 2013. I am not, however, getting the results I expect.
The value being returned for yearweek(25/02/14) is 8, however the week number for this date should be 9. Similarly when I run a report to list of all dates in 2013 with week 8, I get the range 19th February to 25th February. Week 8 in 2013 was actually 18th February to 24th February.
I was wondering whether I am using the function incorrectly, or whether this is in fact an error.
I believe that the yearweek function always uses January 1st to January 7th inclusive as week 1, no matter which day of the week January 1st falls on. And therefore 25/02/14 is day 56 (31 + 25) which is in week 8.
The ISO 8601 definition for week 01 is the week with the year's first Thursday in it. Mutually equivalent definitions would be possible based on the following properties of this week:
If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is part of week 52 or 53 of the previous year.
I will investigate a little further how it is calculated in DE, but Weeks is a nightmare. Every country has its own definition almost. Back in the days of DFD it was like a contest on making the most accurate Week calculation...
In DE the YearWeek is the US version, but what that really imply I need to study a little further before I give a proper answer.
Thank you for the replies.
I have found the following in the Dataease documentation, so I believe Peter is correct:
The yearweek function always counts January 1st - 7th as Week 1, January 8th - 14th as Week 2 etc. In a non-leap year the only day in week 53 is December 31st. In a Leap Year, December 30th is also counted in Week 53.
This is not standard, but it gives me something to work with.