import os,sys
import MySQLdb
import datetime
import time
reload(sys)
sys.setdefaultencoding('utf8')
获取当前月份第一天到最后一天
def getMonth():
year = str(datetime.date.today().year)
d = datetime.date.today()
month = '%02d' % d.month
if month in ['01','03','05','07','08','10','12']:
s = str("-01 00:00:00")
e = str("-31 23:59:59")
startTime = year + "-" + str(month) + s
endTime = year + "-" + str(month) + e
list = [startTime,endTime]
return list
elif month == '02':
s = str("-01 00:00:00")
e = str("-28 23:59:59")
startTime = year + "-" + str(month) + s
endTime = year + "-" + str(month) + e
list = [startTime,endTime]
return list
else:
s = str("-01 00:00:00")
e = str("-30 23:59:59")
startTime = year + "-" + str(month) +s
endTime = year + "-" + str(month) + e
list = [startTime,endTime]
return list