Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

oracle sql date not later than today

Tags:

sql

logic

oracle

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 ?

like image 857
sasori Avatar asked Aug 25 '12 20:08

sasori


People also ask

What is the difference between Sysdate and Systimestamp?

In Oracle, SYSTIMESTAMP is a keyword that returns the system timestamp of the Oracle server. Likewise, SYSDATE is a keyword that returns the system date of the Oracle server.

How can I get tomorrow date in Oracle?

For example, SYSDATE+1 will be tomorrow.

How do I get today's date in SQL Developer?

The SYSDATE() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH:MM:SS" (string) or as YYYYMMDDHHMMSS (numeric).

How do you check if one date is greater than another in Oracle?

You have two options here. One option is to convert the date value to a string and do a string comparison as follows: IF (TO_CHAR(date_val,'YYYY') > '2000') THEN END IF; Another option is to use the TO_DATE function to convert the comparison string to a date value.


1 Answers

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).

like image 177
tbone Avatar answered Sep 25 '22 13:09

tbone