datetime.datetime.strptime('2015.18', "%Y.%W")
datetime.datetime(2015, 1, 1, 0, 0)
Whats wrong with my code? 2015 is Year and 18 is the calendar week?
output is completely wrong. Thank you!
datetime.datetime.strptime('2015.18', "%Y.%W")
datetime.datetime(2015, 1, 1, 0, 0)
Whats wrong with my code? 2015 is Year and 18 is the calendar week?
output is completely wrong. Thank you!
You have to add week day as well to get the desired output.
Following line should work, where 1 is the first day of week.
>>> datetime.datetime.strptime('2015.18.1', "%Y.%U.%w")
datetime.datetime(2015, 5, 4, 0, 0)
Here Sunday is assumed as the first day of the week by python because we are using %U. To set Monday as first day of week use %W or refer to documentation here https://docs.python.org/2/library/datetime.html