Difference between revisions of "Python - datetime"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (New page: =Examples= <pre> #!/usr/bin/env python import datetime start_date = datetime.datetime(2007,01,01) end_date = datetime.datetime(2008,03,11) print start_date print end_date date = st...) |
PeterHarding (talk | contribs) |
||
Line 5: | Line 5: | ||
import datetime | import datetime | ||
start_date = datetime.datetime(2007,01,01) | start_date = datetime.datetime(2007,01,01) | ||
Line 14: | Line 13: | ||
date = start_date | date = start_date | ||
print 'Date' | print 'Date' | ||
Line 23: | Line 21: | ||
date += datetime.timedelta(days=1) | date += datetime.timedelta(days=1) | ||
</pre> | </pre> | ||
[[Category:Python]] |
Revision as of 09:56, 16 April 2008
Examples
#!/usr/bin/env python import datetime start_date = datetime.datetime(2007,01,01) end_date = datetime.datetime(2008,03,11) print start_date print end_date date = start_date print 'Date' while date < end_date: print date.strftime('%Y-%m-%d') date += datetime.timedelta(days=1)