today's Time "2016-12-21"
Get Yesterday date Yyyy-mm-dd
Select Date_sub (Curdate (), Interval 1 day)
2016-12-20
Get the month of yesterday
Select Date_format (Curdate (), '%y-%m ')
2016-12
Date condition: History 12 months
Date condition: History 12 months. = = [current day of the month 1th is the end of time], to [the current month before the 12 months of the 1th number] for start time [start, end]
Select Date_format (Date_sub (Curdate (), Interval month), '%y-%m-01 ') as Start_time, Date_format (Curdate (), '%y-%m-01 ' ) as End_time
start_time |
End_time |
2015-12-01 |
2016-12-01 |
From the beginning of the month to yesterday. || Number 1th to yesterday [Start, end] month to date | |
Select Date_format (Curdate (), '%y-%m-01 ') as Start_time, Curdate () as End_time
start_time |
End_time |
2016-12-01 |
2016-12-21 |
Get Date Yyyymm
Select Extract (Year_month from Curdate ()) as Yyyymm
201612
MySQL Date function