Easy to Create, Easy to Change - Easy to use!


yearweek


Started by Jason Caldwell
Search
You will need to Sign In to be able to add or comment on the forum!

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. 

Written by Jason Caldwell 25/02/14 at 10:50:08 Dataease [{8}]FIVE

Re:yearweek

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.

Written by Peter Birney, PB Associates 01/03/14 at 09:02:02 Dataease [{8}]FIVE

Re:yearweek

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.

Written by Jason Caldwell 01/03/14 at 11:56:42 Dataease [{8}]FIVE

Re:Re:yearweek

First week

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:

  • It is the first week with a majority (4 or more) of its days in January.
  • Its first day is the Monday nearest to 1 January.
  • It has 4 January in it. Hence the earliest possible dates are 29 December through 4 January, the latest 4 through 10 January.
  • It has the year's first working day in it, if Saturdays, Sundays and 1 January are not working days.

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.

Written by DataEase 01/03/14 at 10:06:51 Dataease [{8}]FIVE