일반 숫자를 데이트 형식의 컬럼과 비교할때...
Select *
from xxx
where date > to_date('200802181501','yyyyMMddHh24mi')
만약에 날짜 형식이 20050101000000 이렇게 들어가 있다면
where tdate between to_date('20050101000000', 'yyyymmddhh24miss')
and to_date('20051231000000', 'yyyymmddhh24miss')
위처럼 할 수 있겠죠.
upate는 아래처럼 하시면 됩니다.
update tab1
set date_col1 = date_col1 - 1/24/60/60
date_col - 1 이러면 1일 전이 됩니다.
date_col - 1/24 이러면 1시간 전이 됩니다.
date_col - 1/24/60 이러면 1분 전이 됩니다.
date_col - 1/24/60/60 이러면 1초 전이 됩니다.
참고로 자바에선 시간이 HH 일때는 24시간 hh이면 12시간
즉.. 대소문자로 24시간 표시또는 12시간 표시로 나타납니다.
'일거리 > sql' 카테고리의 다른 글
[sql] MySql 오류==> Table 'xxxxxxxx' is marked as crashed and should be repaired (0) | 2009.08.14 |
---|---|
[sql] Toad에서 script 얻는 방법 (1) | 2009.08.14 |