Created
December 6, 2012 20:22
-
-
Save thinkjson/4227992 to your computer and use it in GitHub Desktop.
Generate time dimension table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Invocation: python time_dimension.py [start_date] [end_date] | |
| """ | |
| from datetime import datetime, timedelta | |
| import sys | |
| start_date = datetime.strptime(sys.argv[1], '%Y-%m-%d') | |
| end_date = datetime.strptime(sys.argv[2], '%Y-%m-%d') | |
| for x in range((end_date - start_date).days + 1): | |
| next_date = start_date + timedelta(x) | |
| print "%s,%s,%s" % (next_date.strftime('%B'), next_date.strftime('%Y'), next_date.strftime('%Y_%m_%d')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice!