Callahan Posted March 27, 2009 Report Share Posted March 27, 2009 Hi all, I have to convert a string like 9 34, which means year 2009 and week number 34 to a string like 090818, whiche means year 2009, month 08 and day 18 (first day of this week). I try to scan my first string to a timestamp with %<%y %W>T format then format this new string with %<%y%m%d>T format but it does'nt work. The problem is to convert the week number. Anybody has an idea ? Thanks all, Callahan Quote Link to comment
Antoine Chalons Posted March 27, 2009 Report Share Posted March 27, 2009 QUOTE (Callahan @ Mar 26 2009, 10:15 AM) Hi all,I have to convert a string like 9 34, which means year 2009 and week number 34 to a string like 090818, whiche means year 2009, month 08 and day 18 (first day of this week). I try to scan my first string to a timestamp with %<%y %W>T format then format this new string with %<%y%m%d>T format but it does'nt work. The problem is to convert the week number. Anybody has an idea ? Thanks all, Callahan Hi, I couldn't find anything related to the week number in the documentation for scanning from a string. The "format date/time string" does support the %W, but the "scan from string" seems not to support it. I assume you will have to read the week number as a integer and do the calculation yourself... Quote Link to comment
jdunham Posted March 27, 2009 Report Share Posted March 27, 2009 QUOTE (Antoine Châlons @ Mar 26 2009, 02:05 AM) I assume you will have to read the week number as a integer and do the calculation yourself... Rather than computing the week number, you could just start with January 1 of that year, and in a while loop, keep adding 24 hours and checking the week number until it matches. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.