mysql 以及 oracle 查询某月份 的全部日期


//mysql 查询当前月份日期
1
SELECT 2 DATE( 3 DATE_ADD( 4 SYSDATE(), 5 INTERVAL - DAY (SYSDATE()) + rs.month_day DAY 6 ) 7 ) AS av 8 FROM 9 ( 10 SELECT 11 @ai := @ai + 1 AS month_day 12 FROM 13 ( 14 SELECT 15 1 16 UNION 17 SELECT 18 2 19 UNION 20 SELECT 21 3 22 UNION 23 SELECT 24 4 25 UNION 26 SELECT 27 5 28 UNION 29 SELECT 30 6 31 ) a, 32 ( 33 SELECT 34 1 35 UNION 36 SELECT 37 2 38 UNION 39 SELECT 40 3 41 UNION 42 SELECT 43 4 44 UNION 45 SELECT 46 5 47 UNION 48 SELECT 49 6 50 ) b, 51 (SELECT @ai := 0) x 52 ) rs 53 WHERE 54 rs.month_day <= DAY (LAST_DAY(SYSDATE()));

  oracle 查询某段时间内的日期

SELECT * FROM (
        SELECT TO_CHAR(TO_DATE(#{beginTime}, 'yyyy-MM-dd') + ROWNUM - 1, 'yyyy-MM-dd') AS DATAS
        FROM DUAL
        CONNECT BY ROWNUM &lt;= TRUNC(TO_DATE(#{endTime}, 'yyyy-MM-dd') - TO_DATE(#{beginTime}, 'yyyy-MM-dd')) + 1
 ) GROUP BY datas
ORDER BY datas

 

posted on 2020-07-07 17:48  Code_任  阅读(549)  评论(0编辑  收藏  举报

导航