怎样取得本月的第一天和本月最后一天?

解决方案 »

  1.   

    SELECT LAST_DAY(SYSDATE) FROM DUAL;
      

  2.   

    sql@sql>select sysdate, trunc(sysdate,'MM') as this_month,
      2     trunc(add_months(sysdate,1),'MM') as next_month
      3  from dual;SYSDATE             THIS_MONTH          NEXT_MONTH
    ------------------- ------------------- -------------------
    2007-06-21 09:55:47 2007-06-01 00:00:00 2007-07-01 00:00:00
      

  3.   

    看错了,sorry.>select sysdate, trunc(sysdate,'MM') as first_d,
      2     trunc(add_months(sysdate,1),'MM')-1 as last_d
      3  from dual;SYSDATE             FIRST_D             LAST_D
    ------------------- ------------------- -------------------
    2007-06-21 09:57:32 2007-06-01 00:00:00 2007-06-30 00:00:00
      

  4.   

    SELECT TRUNC(SYSDATE, 'MONTH')
      "FIRST", LAST_DAY(TRUNC(SYSDATE)) LAST FROM DUAL