標籤:run type round lan pop content family rect rgb
1 取周的開始時間和結束時間
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
2 取月的開始時間和結束時間
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
3 取季的開始時間和結束時間
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
4 取年的開始時間和結束時間
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取周、月、季、年的開始時間和結束時間