Skip to content

Commit

Permalink
adjused date to use the last day of the last month and the first day …
Browse files Browse the repository at this point in the history
…of the current month one year ago
  • Loading branch information
worthink committed Apr 17, 2018
1 parent a4f5596 commit ad0684e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import datetime
from dateutil.relativedelta import relativedelta
import calendar

######
print "load SQL functions"
Expand Down Expand Up @@ -293,8 +294,12 @@ def addWorkSheetFooter(start_col,calc_col_count,pad):
wb = Workbook()
ws = wb.active
#
start_date=(datetime.datetime.now() - relativedelta(years=1)).strftime('%Y-%m-%d')
end_date=datetime.datetime.now().strftime('%Y-%m-%d')
today=datetime.datetime.now() #datetime.date(2016,3, 31)
#rollback to the previous month and create a range from 2017-01-01 - 2017-01-31
_start_date=(today - relativedelta(years=1))
start_date=datetime.date(_start_date.year, _start_date.month,1)
_end_date=(today - relativedelta(months=1))
end_date=datetime.date(_end_date.year, _end_date.month, calendar.monthrange(_end_date.year,_end_date.month)[1]).strftime('%Y-%m-%d')

print "from "+start_date+" to "+ end_date

Expand Down

0 comments on commit ad0684e

Please sign in to comment.