一。基础日期处理
//date 日期处理
select current_date;
select current_timestamp;
//to_date(time) ;to_date(string)
select to_date(current_timestamp);
select to_date(rental_date) from rental limit 10;
month(date/time)
year(date/time)
day(date/time)
second(time)
minute(time)
hour(time)
select hour("22:32:34.0");
select hour(rental_date),count(hour(rental_date)) counts from rental group by hour(rental_date) order by counts;
//注意order by的字段必须要有名字或者别名
unix_timestamp(timestamp)
from_unixtime(unixtime)
//两种时间格式互转
to_utc_timestamp(timestamp,"EST")
from_utc_timestamp(timestamp,"EST")
//于标准时间之间的互转
select unix_timestamp();
select unix_timestamp(current_timestamp);
select from_unixtime(unix_timestamp(current_timestamp));
select from_utc_timestamp(to_utc_timestamp(current_timestamp,"EST"),"EST"),current_timestamp;
二、高级日期时间格式的处理
原文:https://www.cnblogs.com/davidzhu/p/10109250.html