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

How do I convert the sequential day of the year to a date?

P: n/a
I have the sequential day of the year (e.g. 295). I want to convert that to it's equivalent, October 22.
Oct 22 '10 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
You can calculate the date with the datetime module. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> import datetime
  2. >>> datetime.datetime(2010,1,1)
  3. datetime.datetime(2010, 1, 1, 0, 0)
  4. >>> print datetime.datetime(2010,1,1)
  5. 2010-01-01 00:00:00
  6. >>> dt = datetime.datetime(2010,1,1)
  7. >>> dtdelta = datetime.timedelta(days=295)
  8. >>> dt + dtdelta
  9. datetime.datetime(2010, 10, 23, 0, 0)
  10. >>> 
Oct 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.