In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces django how to calculate the date, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Import datetime,timedeltaimport calendarnow = datetime.now () today = datetime.now (). Date () # Today if days= = "1": quesryset = DailyReport.objects.filter (createdate__gte=str (today) + '00lv 00') # yesterday elif days= = "2": end = (now + timedelta (days=-1)). Date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) +' 00lv 0000' Createdate__lte=str (end) + '23elif days= 59end 59') # this week elif days= = "3": end = (now + timedelta (days=-now.isoweekday ()). Date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) +' 00lv 00' Createdate__lte=str (today) +'23 timedelta 59 end 59) # Last week elif days= = "4": end = (now-timedelta (days=7 + now.isoweekday ()). Date () today = (now-timedelta (days=now.isoweekday () + 1)). Date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) + '00Vue 00' Createdate__lte=str (today) + '23elif days= 59end) # this month elif days= = "5": end = (now-timedelta (days=now.day)). Date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) +' 0000VOV, createdate__lte=str (today) + '23Vl59)) # Last month elif days= = "6": last_month = now-timedelta (days=now.day) end_month_days = calendar.monthrange (last_month.year) Last_month.month) [1] end = (last_month-timedelta (days=end_month_days)) .date () today = (now-timedelta (days=now.day+1)) .date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) + '00timedelta 0000' Createdate__lte=str (today) +'23 elif days= 59 end 59) # in the past seven days elif days= = "7": end = (now-timedelta (days=7)) .date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) +'00 end 00' Createdate__lte=str (today) +'23 end 59 end 59) # over the past 30 days, elif days= = "8": end = (now-timedelta (days=30)). Date () quesryset = DailyReport.objects.filter (createdate__gte=str (end) + '0000 end) +' 0000 end, createdate__lte=str (today) +'23 end 59) Thank you for reading this article carefully I hope the article "how to calculate the date of django" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.