Date_add () Increase
MYSQL gets the current time plus one months
Update User set Leverstart=Now (), leverover=1MONTHwhere id= 1;
Date_sub () reduction
Date_sub ('1998-01-01 00:00:00'1 1:1:1' day_second)
Month months
minute min
Second SEC
Hour Hours
Week Week
Quarter Engraved
year
get current time: Now (); Sysdate ()
Get current timestamp function: Current_timestamp, Current_timestamp ()
Date/Time converted to String function: Date_format (Date,format), Time_format (Time,format)
string conversion To date function: Str_to_date (str, format)
date, day conversion function: To_days (date), From_days (days)
time, seconds conversion function: Time_to_sec (times), sec_to_time (seconds)
Select time_to_sec ('01:00:00'-- 3600Select sec_to_ Time (3600-- ' 01:00:00 ' )
Patchwork date, Time function: Makdedate (year,dayofyear), Maketime (Hour,minute,second)
Select makedate (1901,+-- ' 1901-01-30 'select makedate ( 1901,-- ' 2001-02-02 'select maketime (one, one, - -- ' 11:35:30 '
Date, time subtraction function: DateDiff (DATE1,DATE2), Timediff (time1,time2)
Select DateDiff('2008-08-01','2008-08-08');---7SelectTimediff ('2008-08-08 08:08:08','2008-08-08 00:00:00');--08:08:08SelectTimediff ('08:08:08','00:00:00');--08:08:08
Timestamp (timestamp) conversion, increment, decrement function:
Timestamp (date)--date to timestamp
Timestamp (dt,time)--DT + Time
Timestampadd (unit,interval,datetime_expr)--
Timestampdiff (UNIT,DATETIME_EXPR1,DATETIME_EXPR2)--
Select timestamp('2008-08-08');--2008-08-08 00:00:00Select timestamp('2008-08-08 08:00:00','01:01:01');--2008-08-08 09:01:01Select timestamp('2008-08-08 08:00:00','Ten 01:01:01');--2008-08-18 09:01:01SelectTimestampadd ( Day,1,'2008-08-08 08:00:00');--2008-08-09 08:00:00SelectDate_add ('2008-08-08 08:00:00', Interval1 Day);--2008-08-09 08:00:00
Timestampadd () function
SelectTimestampdiff ( Year,'2002-05-01','2001-01-01');---1SelectTimestampdiff ( Day,'2002-05-01','2001-01-01');---485SelectTimestampdiff (Hour,'2008-08-08 12:00:00','2008-08-08 00:00:00');---12Select DateDiff('2008-08-08 12:00:00','2008-08-01 00:00:00');--7
The Timestampdiff () function is stronger than DATEDIFF (), and DateDiff () can only calculate the number of days between two dates (date).
MySQL: Date function, time function processing (RPM)