-
取今天
SELECT TO_CHAR(TRUNC(SYSDATE),'YYYYMMDD') FROM DUAL
-
取上个月今天的前一天
SELECT TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE),-1)-1,'YYYYMMDD') FROM DUAL
-
取本月第一天
SELECT TO_CHAR(TRUNC(SYSDATE,'MM'),'YYYYMMDD') FROM DUAL
-
取本季度第一天
SELECT TO_CHAR(TRUNC(SYSDATE,'Q'),'YYYYMMDD') FROM DUAL
-
取上季度第一天
SELECT TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE,'Q'),-3),'YYYYMMDD') FROM DUAL
-
取今年第一天
SELECT TO_CHAR(TRUNC(SYSDATE,'YYYY'),'YYYYMMDD') FROM DUAL
-
取去年第一天
SELECT TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE,'YYYY'),-12),'YYYYMMDD') FROM DUAL
-
取上周第一天(周日)
SELECT TO_CHAR(TRUNC(SYSDATE,'D')-7,'YYYYMMDD') FROM DUAL
-
取当前时间(24h)
SELECT TO_CHAR(SYSDATE,'HH24') FROM DUAL
-
取当前时间
SELECT TO_CHAR(SYSDATE,'HH') FROM DUAL
-
取当前时间前1s
SELECT TO_CHAR(SYSDATE-1/24/60/60,'YYYY-MM-DD HH24:MI:SS') FROM DUAL
-
取当前时间前1min
SELECT TO_CHAR(SYSDATE-1/24/60,'YYYY-MM-DD HH24:MI:SS') FROM DUAL
-
取当前时间前1h
SELECT TO_CHAR(SYSDATE-1/24,'YYYY-MM-DD HH24:MI:SS') FROM DUAL
-
取今天凌晨1点半
SELECT TO_CHAR(TRUNC(SYSDATE)+1/24+30/24/60,'YYYY-MM-DD HH24:MI:SS') FROM DUAL
Comments