2016年6月28日 星期二

[Oracle Query] 日期格式用法

CASE 
           WHEN TO_CHAR(WDJ.DATE_RELEASED, 'DD') BETWEEN '01' AND '10' THEN '上'
           WHEN TO_CHAR(WDJ.DATE_RELEASED, 'DD') BETWEEN '11' AND '20' THEN '中'
           ELSE '下'
END AS "MONTH",

WDJ.DATE_RELEASED +1 AS "ADD A DAY", --當下日期+1

TRUNC(WDJ.DATE_RELEASED) AS "TRUNC", --把時分秒拿掉

TO_DATE(WDJ.DATE_RELEASED) AS "TO_DATE", --取當下日期

EXTRACT(YEAR FROM WDJ.DATE_RELEASED) AS "EXTRACT", --取年

LAST_DAY(WDJ.DATE_RELEASED) AS "LAST_DAY", --當月最後一天

ADD_MONTHS(WDJ.DATE_RELEASED,1) AS "NEXT MONTH",  --下個月

LAST_DAY(ADD_MONTHS(WDJ.DATE_RELEASED, -1)) AS "END OF LAST MONTH",  --找出前一個月的最後一天

沒有留言:

張貼留言