-
SQL Function
Is there any function in SQL to find difference between two dates in days?
-
minus one date from the other
-
try datediff(date1,date2)
~KD.DBA~
-
Originally Posted by dhar_kiran
try datediff(date1,date2)
That's a Sybase thing, isn't it?
-
Hi Dave,
Can you give the syntax for the same?
-
because i tried like this
SQL> select 20/03/2006 - 21/03/2006 from dual;
20/03/2006-21/03/2006
---------------------
-.00016617
This output look somewhat strange,thats why i asked syntax.
-
Subtract dates
That's because you didn't subtract 2 dates, you just subtracted 2 numbers. You need to use date formats:
Code:
1* select to_date('25-MAY-2006','DD-MON-YYYY') - to_date('23-MAY-2006','DD-MON-YYYY') from dual
SQL> /
TO_DATE('25-MAY-2006','DD-MON-YYYY')-TO_DATE('23-MAY-2006','DD-MON-YYYY')
-------------------------------------------------------------------------
2
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|