Check if current date is between two dates Oracle SQL

前端 未结 3 1361
攒了一身酷
攒了一身酷 2020-11-30 03:42

I would like to select 1 if current date falls between 2 dates through Oracle SQL.

I wrote an SQL after reading through other questions.

https:/

3条回答
  •  鱼传尺愫
    2020-11-30 04:22

    You don't need to apply to_date() to sysdate. It is already there:

    select 1
    from dual 
    WHERE sysdate BETWEEN TO_DATE('28/02/2014', 'DD/MM/YYYY') AND TO_DATE('20/06/2014', 'DD/MM/YYYY');
    

    If you are concerned about the time component on the date, then use trunc():

    select 1
    from dual 
    WHERE trunc(sysdate) BETWEEN TO_DATE('28/02/2014', 'DD/MM/YYYY') AND
                                 TO_DATE('20/06/2014', 'DD/MM/YYYY');
    

提交回复
热议问题