LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Week returned by Format Date/time String

Has anyone tested the Format Date/Time String function with the week formating codes?

I want to create a subfolder for each week and name the folder accordingly. For 17 December 2003 the week is 51 in the year 03 but I get week 50. For 29 December 2003 the week is 01 in the year 04 but I get week 52. For 01 January 2004 the week is 01 in the year 04 but I get week 00. For 29 December 2004 the week is 53 in the year 04 but I get week 52. For 01 January 2005 the week is 53 in the year 04 but I get week 00. There is no difference using %U or %W as code (this will be if 1 January will fall on Sunday or Monday which it does not in my examples).

I know normally a year has weeks 1 to 52 but in some years the last week may have week
53 as in 2004. Adding 1 to the week does not solve the problem. For 29 December 2003 it would give 53. And 53 maybe a correct week as in 2004. For 1 January 2005 it would give 1 but the week is the week in the year before.

All the week numbering I expect is correct for Germany but the function is not. Is the numbering from the function correct for your country?

Please reply where you are located and if the function will work right for you.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 1 of 4
(5,040 Views)
Hello Waldemar,

LabVIEW uses the same definition for week of year as ANSI's strftime function. You might want to read documentation for strftime, although it is basically:
1) Index is zero based (First week is week 0)
2) Week 0 of year n means that the date exists in year n but is before the appropriate first day of week (Monday/Sunday)
3) Week 1 of year n means the date comes after the first appropriate day (Sunday (%U) or Monday (%W)) for the year.
It may be possible to devise a formula to convert the %U to the calendar week number that you need. I don't know what the calendar week is really defined to be (If a week spans 2 years, which year does it belong to? The year in which more days of the week belong?) I would suggest looking at the "Seconds to Date/Ti
me" VI to see if day of year & day of week could be used in a formula to compute the calendar day. I would be interested in any comments/questions you have about this should you wish to post them.
0 Kudos
Message 2 of 4
(5,040 Views)
I have found two resources about date and time and their formats.

One is the ISO Standard 8601, the second is a german page. On this page along with other information all definitions used by Windows is listed.

According to this page the ISO Standard has been established in Europe and most industrial countries. In USA it is ANSI X3.30-1985(R1991) and NIST FIPS 4-1.

Since the ANSI definition you mentioned allows only Sunday (Jewish) or Monday (Christian) as first day of the week it ignores the Islamic world. For them the first day is Saturday. I could not gather information about Buddhistic or Hinduism
based countries.

For my application and the market aimed the ISO format is the one which will be choosen. Using %W and handling of week 0 should do it.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 3 of 4
(5,040 Views)
The german page has also an english version.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 4
(5,040 Views)