好久沒寫部落格了,QAQ
1、擷取目前時間 now() sysdate()
select now()
2018-08-09 18:30:15
select sysdate()
2018-08-09 18:31:39
以上兩個的差別是now()是在sql語句執行時就擷取到了時間,也就是你點選運作時的時間
而sysdate()是擷取執行到sysdate()的時間
select now(),sleep(3),now();
2018-08-09 18:34:18 \ 2018-08-09 18:34:18
select sysdate(),sleep(3),sysdate() ;
2018-08-09 18:36:04 \ 2018-08-09 18:36:01
sleep(int second)指延時多少秒
2、擷取目前時間戳函數
select current_timestamp
2018-08-09 18:40:01
select current_timestamp()
2018-08-09 18:40:01
3、擷取目前時分秒
select current_time
18:38:49
4、Unix 時間戳、日期轉換函數
unix_timestamp(),
unix_timestamp(date),
from_unixtime(unix_timestamp),
from_unixtime(unix_timestamp,format)
select unix_timestamp()
1533811373
select unix_timestamp(“2018-8-8”)
1533657600
select from_unixtime(1533657600,”%Y %D %M %h:%i:%s %x”)
2018 8th August 12:00:00 2018
5、date_add() date_sub() datediff()函數
select datediff(“2015-11-16”,now())
-997
select timestampdiff(day,”2015-11-16”,now())
997
具體可參考http://www.cnblogs.com/ggjucheng/p/3352280.html,感謝!!!!