时间:2021-07-01 10:21:17 帮助过:9人阅读
取周的開始时间。以星期一为開始。
SQL>SELECT TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘),‘D‘) + 1 ASA FROM DUAL;
A
-----------
2013/11/25
取周的结束时间。以星期日为结束
SQL>SELECT TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘),‘D‘) + 7 ASA FROM DUAL;
A
-----------
2013/12/1
取月的開始时间
SQL>SELECT TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘),‘MM‘) AS AFROM DUAL;
A
-----------
2013/11/1
取月的结束时间
SQL>SELECT LAST_DAY(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘)) AS AFROM DUAL;
A
-----------
2013/11/30
取季的開始时间
SQL>SELECT TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘),‘Q‘) AS AFROM DUAL;
A
-----------
2013/10/1
取季的结束时间
SQL>SELECT ADD_MONTHS(TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DDHH24:MI:SS‘),‘Q‘),3)-1 AS A FROM DUAL;
A
-----------
2013/12/31
取年的開始时间
SQL>SELECT TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DD HH24:MI:SS‘),‘YYYY‘) ASA FROM DUAL;
A
-----------
2013/1/1
取年的结束时间
SQL>SELECT ADD_MONTHS(TRUNC(TO_DATE(‘2013-11-25 10:31:11‘,‘YYYY-MM-DDHH24:MI:SS‘),‘YYYY‘),12)-1 AS A FROM DUAL;
A
-----------
2013/12/31
ORACLE取周、月、季、年的開始时间和结束时间
标签:run type round lan pop content family rect rgb