|
Ok, WEEK_ISO works pretty good. However if you plan on doing something like passing a date and getting YYW## where yy=year and ##=week number then you better be careful. If Month of that date is 01 and the week >6 then subtract 1 from the year. For example 2000-01-01=1999-W52-6. Gee, don't you think another few date formats are needed to support week notation with/without separators and with/without the day of the week? Copying from: http://www.cl.cam.ac.uk/~mgk25/iso-time.html In commercial and industrial applications (delivery times, production plans, etc.), especially in Europe, it is often required to refer to a week of a year. Week 01 of a year is per definition the first week that has the Thursday in this year, which is equivalent to the week that contains the fourth day of January. In other words, the first week of a new year is the week that has the majority of its days in the new year. Week 01 might also contain days from the previous year and the week before week 01 of a year is the last week (52 or 53) of the previous year even if it contains days from the new year. A week starts with Monday (day 1) and ends with Sunday (day 7). For example, the first week of the year 1997 lasts from 1996-12-30 to 1997-01-05 and can be written in standard notation as 1997-W01 or 1997W01 The week notation can also be extended by a number indicating the day of the week. For example, the day 1996-12-31, which is the Tuesday (day 2) of the first week of 1997, can also be written as 1997-W01-2 or 1997W012 for applications like industrial planning where many things like shift rotations are organized per week and knowing the week number and the day of the week is more handy than knowing the day of the month. An abbreviated version of the year and week number like 95W05 Rob Berendt -- "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." Benjamin Franklin select mydate,week_iso(mydate) from rob/a7 will return: MYDATE WEEK_ISO ( MYDATE ) 01/01/00 52 01/02/00 52 01/03/00 1 01/04/00 1 01/01/02 1 01/07/02 2 01/06/02 1 select mydate,week(mydate) from rob/a7 will return: MYDATE WEEK ( MYDATE ) 01/01/00 1 01/02/00 2 01/03/00 2 01/04/00 2 01/01/02 1 01/06/02 2 01/07/02 2 Two problems: 1) 01/01/00 was on a Saturday. Thus the first week began with Monday 01/03/00. 2) Sunday's are the last day of a week, not the first.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.