详情查看:https://www.cnblogs.com/feiyumo/p/8760846.html
以防止文章丢失,我搬运过来。 !!!转载自飞末!!!
2018-04-09
2018-04-09 15:20:49.247
Examples:> SELECT day('2009-07-30');
30
Examples:> SELECT dayofweek('2009-07-30');
5
Since: 2.3.0
weekofyear(date) - Returns the week of the year of the given date. A week is considered to start on a Monday and week 1 is the first week with >3 days.
Examples:> SELECT weekofyear('2008-02-20');
8
Examples:> SELECT date_format('2016-04-08', 'y');
2016
Examples:
> SELECT unix_timestamp(); 1476884637
> SELECT unix_timestamp('2016-04-08', 'yyyy-MM-dd'); 1460041200
Examples:
> SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ss'); 1970-01-01 00:00:00
>SELECT to_unix_timestamp('2016-04-08', 'yyyy-MM-dd');
1460041200
> SELECT to_date('2009-07-30 04:17:52'); 2009-07-30
> SELECT to_date('2016-12-31', 'yyyy-MM-dd'); 2016-12-31
> SELECT to_timestamp('2016-12-31 00:12:00'); 2016-12-31 00:12:00
Examples:> SELECT quarter('2016-08-31');
3
months_between(timestamp1, timestamp2) - Returns number of months between timestamp1
and timestamp2
.
Examples:> SELECT months_between('1997-02-28 10:30:00', '1996-10-30');
3.94959677
Examples:> SELECT add_months('2016-08-31', 1);
2016-09-30
Examples:
> SELECT last_day('2009-01-12'); 2009-01-31
> SELECT next_day('2015-01-14', 'TU'); 2015-01-20
date_add(start_date, num_days) - Returns the date that is num_days
after start_date
.
Examples:
> SELECT date_add('2016-07-30', 1); 2016-07-31
datediff(endDate, startDate) - Returns the number of days from startDate
to endDate
.
Examples:> SELECT datediff('2009-07-31', '2009-07-30');
1