MySQL Modify time function:
1. Adddate (date,interval expr unit) INTERVAL represents the time interval :
SELECT now (); 2018-06-20 15:00:00--Current time
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-60 SECOND) as time; 2018-06-20 14:59:00--minus 60 seconds
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-1 MINUTE) as time; 2018-06-20 14:59:00--minus 1 minutes
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-1 HOUR) as time; 2018-06-20 14:00:00--minus 1 hours
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-1 Day) as time; 2018-06-19 15:00:00-minus 1 days
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-1 MONTH) as time; 2018-05-20 15:00:00--minus 1 months
SELECT adddate (' 2018-06-20 15:00:00 ', INTERVAL-1 year) as time; 2017-06-20 15:00:00--minus 1 years
Link: 55259766 (mysql date and character conversion method )
2. Date_format (date, '%y-%m-%d ') ———— to_char () in –>oracle;
3. Str_to_date (date, '%y-%m-%d ') ———— to_date () in –>oracle;
%Y: Represents a 4-digit year
%y: Represents the year of 2
%m: Represents the month, in the form of (01 ... 12)
%c: Represents the month in the format of (1 ... 12)
%d: Represents the number of days in the month in the format (00 ...). 31)
%e: Represents the number of days in the month in the format (0 ...). 31)
%H: Represents the hour, in the form of (00 ... 23)
%k: Represents the hour, in the form of (0 ... 23)
%h: Represents the hour, in the form of (01 ... 12)
%I: Represents the hour, in the form of (01 ... 12)
%l: Represents the hour, in the form of (1 ... 12)
%i: Represents minutes, in the form of (00 ... 59) "Only this one represents minutes, the uppercase I does not represent minutes for the hour"
%r: Represents the time, in the format of 12 hours (Hh:mm:ss [ap]m)
%T: Represents the time, in the format of 24 hours (HH:MM:SS)
%s: represents seconds in the format (00 ...). 59)
%s: represents seconds in the format (00 ...). 59)
MySQL Modify Time function adddate (date, INTERVAL expr unit)