728x90
insert into people2
(name,birthdate,birthtime,birthdt)
values
('Mike','1990-11-11','10:07:35','1983-11-11 10:07:35'),
('Larry','1972-12-25','04:10:42','1990-12-25 04:10:42');
-- db에 저장된 시간형식의 데이터를
-- 사람이 보기 편한 데이터로 바꾸는 방법 date_format()
select date_format(birthdt,'%Y년 %m월 %d일,%h시%m분%s초')
from people2;
- 시간의 차이를 구하는 방법 datediff() => 날짜로
select datediff( now() , birthdt )
from people2;
date_add()
select birthdt, date_add(birthdt,interval 1 day)
from people2;
'MySQL' 카테고리의 다른 글
MySQL - group by에서 Having을 사용하는 방법 (0) | 2022.12.07 |
---|---|
MySQL- is null : null인 데이터를 가져오는 방법 (0) | 2022.12.07 |
MySQL - 의 현재 Datetime 정보 가져오는 함수 curdate(), curtime(),now() (0) | 2022.12.07 |
MySQL - 날짜와 시간 처리 datetime테이블 설정 및 원하는 연,월,일,요일 출력 (0) | 2022.12.07 |
MySQL not equal(~가 아닌 것) , not like (~를 포함하지 않은 것) 데이터 가져오기. (0) | 2022.12.07 |