When I am trying to calculate the date difference by using datediff function it showing that invalid identifier.
SELECT DATEDIFF(day,'2008-08-05','2008-06-05') AS DiffDate from da_static_trade.
Error : invalid identifier.
Can you please tell me what is the function to calculate date difference.
To calculate the difference between the timestamps in Oracle, simply subtract the start timestamp from the end timestamp (here: arrival - departure ). The resulting column will be in INTERVAL DAY TO SECOND .
The DATEDIFF() function returns the difference between two dates.
You can use "classic comparators" (like >, >=, <, =...) to compare 2 dates. If you have date data types : don't convert them. if you have no choice, use something like: if to_char(d1,'YYYYMMDD') > to_char(d2,'YYYYMMDD') then ... else ...
Just subtract the two date values. For example: SELECT SYSDATE - TO_DATE('03-02-1996','MM-DD-YYYY') FROM dual; The result is fractional in days.
There is no DATEDIFF()
function in Oracle. On Oracle, it is an arithmetic issue
select DATE1-DATE2 from table
You can not use DATEDIFF
but you can use this (if columns are not date type):
SELECT
to_date('2008-08-05','YYYY-MM-DD')-to_date('2008-06-05','YYYY-MM-DD')
AS DiffDate from dual
http://sqlfiddle.com/#!4/d41d8/34609
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