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 ?
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.
For example, SYSDATE+1 will be tomorrow.
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).
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With