노트: 흔히 볼 수 있는 시간 함수

1135 단어
select current_date(), curdate(), curdate() + 0;     
# '2018-03-09' '2018-03-09'  20180309

select current_time(), curtime(), curtime() + 0;      
# 16:49:41  16:49:41  164941

select current_time(2), curtime(2), curtime(2) + 0;   
# 16:50:50  16:50:50  165050.01 

select now(), now(3), now(6);
# 2018-03-09 16:53:51       2018-03-09 16:53:51.163        2018-03-09 16:53:51.163791

select current_date() 
#2018-05-30

select  DATE_FORMAT(APPOINTMENT_TIME,'%Y-%m-%d') = CURRENT_DATE()

select  DATE_FORMAT(current_date()-1, '%Y-%m-%d') 
#2018-05-29
 
select  DATE_FORMAT(current_date()-31, '%Y-%m-%d') -- 
 
select  DATE_FORMAT(date_sub(current_date(), interval 1 day), '%Y-%m-%d') 
# 2018-05-29
 
select  DATE_FORMAT(date_sub(current_date(), interval 31 day), '%Y-%m-%d')  
# 2018-04-29
 
select  DATE_SUB(current_date, INTERVAL 35 DAY)  
# 2018-04-25
 
select CONCAT(DATE_FORMAT(current_time(),'%H:%i'),'~',DATE_FORMAT(current_time(),'%H:%i'))  
# 20:30~20:30

#      
DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s')

좋은 웹페이지 즐겨찾기