oracle sql date not later than today

ぃ、小莉子 提交于 2019-12-03 11:03:52

问题


I need to display some data if it's a - new data - updated data let's say, I will be basing these data from a publishdate column and updated column where publishdate and updateddate are both timestamps ? . so how to compute the date if it's a new one ?


回答1:


For last 24 hours:

Where publish_date >= sysdate -1

or anytime today (midnight forward)

where publish_date >= trunc(sysdate)

If this is a big table, I assume you have an index on publish_date. If you use trunc(publish_date), it may not be able to use the index (untested, but run an explain plan to be sure).




回答2:


Try this

Where TRUNC(sysdate) = TRUNC(publish_date)

sysdate returns today's date with the time. The TRUNC removes the time part



来源:https://stackoverflow.com/questions/12125401/oracle-sql-date-not-later-than-today

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!