import datatime
date = datetime.datetime.now()
newdate = datetime.datetime.now()
condtions = {‘datadate’: newdate}
newdate = date + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
newdate = now - datetime.timedelta(days=now.weekday())
condtions = {‘datadate’: newdate}
newdate = now + datetime.timedelta(days=6 - now.weekday())
condtions = {‘datadate’: newdate}
newdate = now - datetime.timedelta(days=now.weekday() + 7)
condtions = {‘datadate’: newdate}
newdate = now - datetime.timedelta(days=now.weekday() + 1)
condtions = {‘datadate’: newdate}
newdate = date.replace(day=1)
condtions = {‘datadate’: newdate}
year = date.year
month = date.month
a, b = calendar.monthrange(year, month) # a,b——weekday的第一天是星期几(0-6对应星期一到星期天)和这个月的所有天数
newdate = datetime.datetime(year=year, month=month, day=b) # 构造本月月末datetime
condtions = {‘datadate’: newdate}
date_now = date.replace(day=1)
date_now = date_now + datetime.timedelta(days=-1)
newdate = datetime.datetime(date_now.year, date_now.month, 1)
condtions = {‘datadate’: newdate}
date_now = date.replace(day=1)
newdate = date_now + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
newdate = date.replace(month=1, day=1)
condtions = {‘datadate’: newdate}
newdate = date.replace(month=12, day=31)
condtions = {‘datadate’: newdate}
newdate = date.replace(month=1, day=1)
newdate = newdate + datetime.timedelta(days=-1)
newdate = datetime.datetime(newdate.year, 1, 1)
condtions = {‘datadate’: newdate}
newdate = date.replace(month=1, day=1)
newdate = newdate + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 3 + 1
newdate = datetime.datetime(date.year, month, 1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 3 + 1
if month == 10:
newdate = datetime.datetime(date.year + 1, 1, 1) + datetime.timedelta(days=-1)
else:
newdate = datetime.datetime(date.year, month + 3, 1) + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 3 + 1
newdate = datetime.datetime(date.year, month, 1)
newdate = newdate + datetime.timedelta(days=-1)
newdate = datetime.datetime(newdate.year, newdate.month - 2, 1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 3 + 1 # 10
newdate = datetime.datetime(date.year, month, 1)
newdate = newdate + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 6 + 1
newdate = datetime.datetime(date.year, month, 1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 6 + 1
if month == 7:
newdate = datetime.datetime(date.year + 1, 1, 1) + datetime.timedelta(days=-1)
else:
newdate = datetime.datetime(date.year, month + 6, 1) + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 6 + 1
newdate = datetime.datetime(date.year, month, 1)
newdate = newdate + datetime.timedelta(days=-1)
newdate = datetime.datetime(newdate.year, newdate.month - 5, 1)
condtions = {‘datadate’: newdate}
month = (date.month - 1) - (date.month - 1) % 6 + 1
newdate = datetime.datetime(date.year, month, 1)
newdate = newdate + datetime.timedelta(days=-1)
condtions = {‘datadate’: newdate}
ms_newdate = date.replace(day=1)
me_newdate = date
new_date = (ms_newdate, me_newdate)
month = (date.month - 1) - (date.month - 1) % 3 + 1
ss_newdate = datetime.datetime(date.year, month, 1)
se_newdate = date
new_date = (ss_newdate, se_newdate)
month = (date.month - 1) - (date.month - 1) % 6 + 1
hs_newdate = datetime.datetime(date.year, month, 1)
he_newdate = date
new_date = (hs_newdate, he_newdate)
ys_newdate = date.replace(month=1, day=1)
ye_newdate = date
new_date = (ys_newdate, ye_newdate)
if condtions:
query_res = Entry.objects.filter(**condtions).filter().exclude()
if new_date:
query_res = Entry.objects.filter(datadate__range=new_date).filter().exclude()