By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 443,898 Members | 1,198 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

"week-year" conversion to date

 P: n/a I was wondering if it there is an "easy" way to get the dd-mm-yyyy from ww-yyyy. I would like to get, for example the first day (date-month-year) in the week i specify. Found plenty of ways to go th other way, but none that give me the reverse. Idealy I would like both the beginning date/time and the end date/time of the specified week, but if i can just get a hold one of the or some other defined time in this week i could probably work out the rest. This is in Python :-) dd = day in month mm = month yyyy = year ww = week # Thanks for any and all help. Sep 14 '05 #1
Share this Question
4 Replies

 P: n/a year = '2005' week = 50 weekday = 1 # Monday is 1 time_expr = '%s, %s, %s' % (year, week, weekday) time_struct = time.strptime(time_expr, "%Y, %W, %w") print time.strftime("%Y%m%d", time_struct) But the datetime module may have an easier way Sep 14 '05 #2

 P: n/a oy***@hotmail.com writes: I was wondering if it there is an "easy" way to get the dd-mm-yyyy fromww-yyyy. I would like to get, for example the first day (date-month-year) in theweek i specify. Found plenty of ways to go th other way, but none thatgive me the reverse. Idealy I would like both the beginning date/time and the end date/timeof the specified week, but if i can just get a hold one of the or someother defined time in this week i could probably work out the rest. This is in Python :-) dd = day in monthmm = monthyyyy = yearww = week # Thanks for any and all help. import mx.DateTime d=mx.DateTime.DateTime(1992)+mx.DateTime.RelativeD ateTime(weeks=15) d d=mx.DateTime.DateTime(1992)+mx.DateTime.RelativeD ateTime(weeks=51) d Eddie Sep 14 '05 #3

 P: n/a Thanks! Both solutions worked perfectly. Sep 15 '05 #4

 P: n/a On 14 Sep 2005 06:26:01 -0700, oy***@hotmail.com wrote: I was wondering if it there is an "easy" way to get the dd-mm-yyyy from ww-yyyy. Note that there are different standards[0] for assigning numbers to weeks in a year. Whatever software or algorithm you use, make sure it documents which one it implements. /Jorgen [0] If I recall correctly, one is an ISO standard and is the used in Sweden and in BSD ncal(1), but there are others that could be in common use in parts of the world. -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! Sep 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.