I would like to ask how do i check if the difference between two dates.
-
BillingDate which is a date type with an entry ‘DD-MON-YYYY’
-
and the other date is the current date.
sys_date - BillingDate = daysFromBilled
alot of the examples i find they actually stated the second date to calculate the difference but what i am looking for is the difference between the current date so i can add it into a schedule or job.
i am using oracle btw.
Another point to add, i will continue to search, but if your could also recommend, how should i implement such a function:
- Calculate date difference from all BillingDate entries
- To trigger an alter table if the difference is more than 30 days to put Status as Late.
- If Status is more than 60 days the Service attribute will be altered and changed to Cut
here is my rough table layout
Cust Billing
-------- ----------
CustID(PK) BillingID(PK)
LateStatus LateStatus
Service BillingDate
CustID
Thanks alot.
Update
REPLACE view DateDifference as
select trunc(sysdate)- trunc(BillingDate)
from Billing;
seems legit.
Simply subtract one date from the other:
To do that in a select statement, just use it like this:
Inside a trigger you use a regular assignment operator:
that will return the number of days, including fractional values if the time is different (a
DATEcolumn in Oracle also contains a time!).If you only want to get full days, use this:
This statement of yours:
Indicates a misunderstanding on how
DATEvalues work.A
DATE(orTIMESTAMP) does not have any format.They are stored in binary form in your column. The format is only applied when you display the value and thus convert it to a character literal. That is the work of the client application you use to display the values. SQL*Plus uses the NLS settings, other SQL tools might use a different configuration.