-- 시간을 처리하는 방법
-- date, time, datetime
-- date YYYY-MM-DD
-- time HH:MM:SS
-- datetime YYYY-MM-DD HH:MM:SS
insert into people2
(name, birthdate, birthtime, birthdt)
values
('Padma', '1988-11-11', '10:07:35', '1988-11-11 10:07:35'),
('Larry', '1994-04-22' , '04:10:42', '1994-04-22 04:10:42');
select *
from people2;
-- 현재 시간과 관련된 함수 3개, curdate(), curtime(), now()
select now();
insert into people2
(name, birthdate, birhtime, birthdt)
values
('Harry', curdate(), curtime(), now() );
select *
from people2;
select name, year(birthdate)
from people2;
select name, month(birthdate)
from people2;
select name, day(birthdate)
from people2;
select name, dayofweek(birthdate)
from people2;
select date_format(birthdt, '%Y-%m-%d %H:%i 에 태어났습니다.')
from people2;
-- birthdate 컬럼과 현재시간의 차이를 가져오세요.
select datediff( now() , birthdate) -- now 빼기 벌스데이 하라는 뜻의 코드임.
from people2;
-- birthdate에 36일 후는??
select date_add(birthdate, interval 36 day)
from people2;
select birthdate + interval 28 week
from people2;
select birthdt + interval 16 hour
from people2;
select birthdt + interval 2 year + interval 3 month - interval 5 hour
from people2;
-- date, time, datetime 데이터 타입에 대해서 배웠다.
-- timestamp 데이터타입 ==> 날짜를 숫자로 표현, 1970년 1월1일 자정을 0으로 시작a
-- 지금까지 흘러온 초
-- date, time, datetime 데이터 타입에 대해서 배웠다.
-- timestamp 데이터타입 ==> 날짜를 숫자로 표현, 1970년 1월1일 자정을 0으로 시작a
-- 지금까지 흘러온 초