데이터베이스

MySQL 현재시간호출,시간차이,날짜더하기,date_format :datediff/date_add

공부짱짱열심히하기 2022. 12. 8. 23:12

 

select curdate();

select curtime();

select now();

 

 

 

 

시간은 UTC 협정시간으로 출력 되기 때문에 9시간 차이가 난다.

 


iso형식의 시간을 한글로 표현하기

 

select date_format(컬럼,'%Y년 %m월 %d일,%h시%m분%s초')
from 테이블;


날짜에서 지금까지 날짜차이구하기

select datediff( now() , 날짜컬럼 )
from 테이블;

 


날짜 더하기

select birthdt, date_add(날짜컬럼,interval n day)
from 테이블;

 

 


현재의 연월일 정보 호출
select curdate();

현재의 시간을 호출
select curtime();

현재의 연월일 시분초 호출
select now();

시간은 UTC 협정시간으로 출력 되기 때문에 9시간 차이가 난다.


iso형식의 시간을 한글로 표현하기
select date_format(컬럼,'%Y년 %m월 %d일,%h시%m분%s초')
from 테이블;

날짜에서 지금까지 날짜차이 구하기
select datediff( now() , 날짜컬럼 )
from 테이블;

날짜 더하기
select birthdt, date_add(날짜컬럼,interval n day)
from 테이블;