ORACLE sql Date: 获取一月到当前月
Sql
SELECT ITEM_DATE, TO_CHAR(ITEM_DATE, 'YYYY-MM-DD') CURRENT_DATE_STR, CURRENT_YEAR, CASE TO_CHAR(ITEM_DATE, 'MM') WHEN '01' THEN 'JAN' WHEN '02' THEN 'FEB' WHEN '03' THEN 'MAR' WHEN '04' THEN 'APR' WHEN '05' THEN 'MAY' WHEN '06' THEN 'JUN' WHEN '07' THEN 'JUL' WHEN '08' THEN 'AUG' WHEN '09' THEN 'SEP' WHEN '10' THEN 'OCT' WHEN '11' THEN 'NOV' WHEN '12' THEN 'DEC' ELSE '' END AS MONTH FROM ( SELECT ADD_MONTHS(CURRENT_TIMESTAMP, 1 - LEVEL) ITEM_DATE, TO_CHAR(CURRENT_TIMESTAMP, 'YYYY') CURRENT_YEAR FROM DUAL CONNECT BY LEVEL <= 13 ) V WHERE CURRENT_YEAR = TO_CHAR(ITEM_DATE,'YYYY') ;
Result