Skip to content

Instantly share code, notes, and snippets.

@thinkjson
Created December 6, 2012 20:22
Show Gist options
  • Select an option

  • Save thinkjson/4227992 to your computer and use it in GitHub Desktop.

Select an option

Save thinkjson/4227992 to your computer and use it in GitHub Desktop.
Generate time dimension table
"""
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'))
@xxyjoel
Copy link
Copy Markdown

xxyjoel commented Oct 11, 2019

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment