@today value = date.today().strftime("%Y-%m-%d") @yesterday value = (date.today()-timedelta(days=1)).strftime("%Y-%m-%d") @lastyeartoday cmonth = date.today().month cyear = date.today().year cday = date.today().day if cmonth == 2 and cday == 29: cday = 28 value = date(cyear-1,cmonth,cday).strftime("%Y%-m-%d0000") @nextyeartoday cmonth = date.today().month cyear = date.today().year cday = date.today().day if cmonth == 2 and cday == 29: cday = 28 value = date(cyear+1,cmonth,cday).strftime("%Y-%m-%d") @lastweek value = (date.today()-timedelta(days=7)).strftime("%Y-%m-%d") @nextweek value = (date.today()+timedelta(days=8)).strftime("%Y-%m-%d") @currentyear value = date(date.today().year,1,1).strftime("%Y-%m-%d") @currentquarter quarter = (date.today().month-1)//3 + 1 first_month = quarter * 3 - 2 value = date(date.today().year,first_month,1).strftime("%Y-%m-%d") @currentquarter_end quarter = (date.today().month-1)//3 + 1 last_month = quarter * 3 if last_month == 12: value = (date(date.today().year+1,1,1)-timedelta(days=1)).strftime("%Y-%m-%d") else: value = (date(date.today().year,last_month+1,1)-timedelta(days=1)).strftime("%Y-%m-%d") @lastquarter quarter = (date.today().month-1)//3 + 1 if quarter > 1: first_month = (quarter-1) * 3 - 2 value = date(date.today().year,first_month,1).strftime("%Y-%m-%d") else: first_month = 10 value = date(date.today().year-1,first_month,1).strftime("%Y-%m-%d") @lastquarter_end quarter = (date.today().month-1)//3 + 1 if quarter > 1: last_month = (quarter-1) * 3 value = (date(date.today().year,last_month+1,1)-timedelta(days=1)).strftime("%Y-%m-%d") else: value = (date(date.today().year,1,1)-timedelta(days=1)).strftime("%Y-%m-%d") @currentquarter_n value = str((date.today().month-1)//3 + 1) @lastquarter_n value = str((date.today().month-1)//3 + 1) @lastyear value = date(date.today().year-1,1,1).strftime("%Y-%m-%d") @nextyear value = date(date.today().year+1,1,1).strftime("%Y-%m-%d") @currentmonth value = date(date.today().year,date.today().month,1).strftime("%Y-%m-%d") @currentmonth_end month = date.today().month if month == 12: value = (date(date.today().year+1,1,1)-timedelta(days=1)).strftime("%Y-%m-%d") else: value = (date(date.today().year,date.today().month+1,1)-timedelta(days=1)).strftime("%Y-%m-%d") @halfayearago hyear = date.today().year hymonth = date.today().month - 6 if hymonth <= 0: hyear = hyear - 1 hymonth = 12 - hymonth value = date(hyear,hymonth,1).strftime("%Y-%m-%d") @lastmonth cmonth = date.today().month cyear = date.today().year if cmonth > 1: cmonth = cmonth-1 else: cmonth = 12 cyear = cyear -1 value = date(cyear,cmonth,1).strftime("%Y-%m-%d") @lastmonth_end value = (date(date.today().year,date.today().month,1)-timedelta(days=1)).strftime("%Y-%m-%d") @30days_ago value = (date.today()-timedelta(days=30)).strftime("%Y-%m-%d") @nextmonth cmonth = date.today().month cyear = date.today().year if cmonth < 12: cmonth = cmonth+1 else: cmonth = 1 cyear = cyear + 1 value = date(cyear,cmonth,1).strftime("%Y-%m-%d") @nextmonth_end month = date.today().month if month >= 11: if month == 11: value = (date(date.today().year+1,1,1)-timedelta(days=1)).strftime("%Y-%m-%d") else: value = (date(date.today().year+1,2,1)-timedelta(days=1)).strftime("%Y-%m-%d") else: value = (date(date.today().year,date.today().month+2,1)-timedelta(days=1)).strftime("%Y-%m-%d") @today3weeks value = (date.today()+timedelta(days=21)).strftime("%Y-%m-%d") @currentyear_yyyy value = date.today().strftime("%Y") @lastyear_yyyy value = str(date.today().year-1) @nextyear_yyyy value = str(date.today().year+1) @lastmonth_mm if not date.today().month-1: value = "12" else: value = str(date.today().month-1) @currentmonth_mm value = str(date.today().month) @nextmonth_mm if date.today().month+1 > 12: value = "1" else: value = str(date.today().month+1)