[참고] 관련포스트
1 2 3 4 5 6 | SELECT SYSDATE now, SYSDATE+30/(24*60*60) now_plus_30_secs FROM dual; -- 원하는 날짜 형식으로 출력하는 쿼리문 SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') NOW, TO_CHAR(SYSDATE+30/(24*60*60),'YYYY-MM-DD HH24:MI:SS') NOW_PLUS_30_SECS FROM DUAL; |
1 2 3 4 5 6 7 8 9 | SELECT SYSDATE NOW, SYSDATE+1/24 , SYSDATE +1/1440 , SYSDATE + 1/86400 FROM DUAL; -- 원하는 날짜 형식으로 출력하는 쿼리문 SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'), --NOW TO_CHAR(SYSDATE+1/24, 'YYYY-MM-DD HH24:MI:SS'), --One hour from now TO_CHAR(SYSDATE +1/1440, 'YYYY-MM-DD HH24:MI:SS'), --1 minutes from now TO_CHAR(SYSDATE + 1/86400,'YYYY-MM-DD HH24:MI:SS') -- 1 seconds from now FROM DUAL; |
* 날짜 관련 계산하기 표현
Description | Date Expression |
Now | SYSDATE |
Tomorrow/ next day | SYSDATE + 1 |
Seve days from now | SYSDATE + 7 |
One hour from now | SYSDATE + 1/24 |
Three hours from now | SYSDATE + 3/24 |
An half hour from now | SYSDATE + 1/48 |
10 minutes from now | SYSDATE + 10/1440 |
30 seconds from now | SYSDATE + 30/86400 |
Tomorrow at 12 midnight | TRUNC(SYSDATE + 1) |
Tomorrow at 8 AM | TRUNC(SYSDATE + 1) + 8/24 |
Next Monday at 12:00 noon | NEXT_DAY(TRUNC(SYSDATE),'MONDAY')+12/24 |
First day of the month at 12 midnight | TRUNC(LAST_DAY(SYSDATE)+1) |
The next Monday, Wendesday or Friday at 9 a.m | TRUNC(LEAST(NEXT_DAY(sysdate,''MONDAY'' ), NEXT_DAY(sysdate,''WEDNESDAY''), NEXT_DAY(sysdate,''FRIDAY'' ))) + (9/24) |
[추가]
[코드] | ||
| ||
-- 지정된 범위에서 날짜를 반올림하는 / 자르는 함수 ROUND/TRUNC(날짜 , 포맷) 출력하기 좋게 쿼리 변경.
[출처] [오라클] 날짜관련 계산하기(1)|작성자 |