如果当前日期通过oracle sql在2个日期之间,我想选择1.
在阅读其他问题后,我写了一个sql
https://stackoverflow.com/questions/2369222/oracle-date-between-query
但它只返回null. sysdate是日期格式为DD / MM / YYYY的01/05/2014的当前日期.
我写的sqls如下:
select 1 from dual WHERE to_date(sysdate,'DD/MM/YYYY') BETWEEN TO_DATE('28/02/2014','DD/MM/YYYY') AND TO_DATE('20/06/2014','DD/MM/YYYY');
和
select 1 from dual WHERE to_date(sysdate,'DD/MM/YYYY') >= TO_DATE('28/02/2014','DD/MM/YYYY') AND to_date(sysdate,'DD/MM/YYYY') < TO_DATE('20/06/2014','DD/MM/YYYY');
在此先感谢您的帮助.
您不需要将to_date()应用于sysdate.已经在那里了
原文链接:https://www.f2er.com/oracle/205279.htmlselect 1 from dual WHERE sysdate BETWEEN TO_DATE('28/02/2014','DD/MM/YYYY') AND TO_DATE('20/06/2014','DD/MM/YYYY');
如果您关心日期的时间组件,则使用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');