-
MySQL 현재날짜, 현재시간 함수, DateTime 변환 등 날짜 관련 정보Database/Oracle & MySQL 2020. 11. 24. 16:35반응형
MSSQL에서 현재날짜시간에 대한 함수는 getdate()이다.
이와 같이 MySQL에서도 현재날짜시간을 알려주는 함수가 존재하며,
MySQL에서 현재날짜시간을 알려주는 함수는 now()이다.
SELECT now();
now()함수의 자료형은 DateTime이다.
DateTime형을 원하는 자료로 변환하는 방법
간단하게 now()에서 날짜만 표기하려면 DATE_FORMAT(now(), '%Y-%m-%d'); 을 사용한다.
그 외의 필요한 포맷 형식들 및 포맷 방법들, 날짜와 관련된 함수들은 아래 MySQL 공식 홈페이지에서 확인한다.
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format
MySQL :: MySQL 5.7 Reference Manual :: 12.7 Date and Time Functions
12.7 Date and Time Functions This section describes the functions that can be used to manipulate temporal values. See Section 11.2, “Date and Time Data Types”, for a description of the range of values each date and time type has and the valid formats
dev.mysql.com
반응형'Database > Oracle & MySQL' 카테고리의 다른 글
MySQL에서 ROW_NUMBER, ROWNUM처럼 번호 매기는 방법, 구한 것을 UPDATE 하기 (0) 2021.03.04 [펌] 오라클(11g R2) 완전히 삭제하는 방법 (0) 2019.05.30