Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

datediff equivalent in Oracle

431158Jul 4 2005 — edited Jul 4 2005
Hi,

In SQL Server, there is a function datediff with datepart 'q'/quarter which behaves as follows :--

select datediff(q,'03-30-2005','04-01-2005') will return 1

datediff(q,start date,end date)

i.e it takes the quarter in which the start date exists and subtracts it from the quarter in which the end date exists.

I need the equivalent for the above in Oracle.

I found the below in OMWB document :--

Equivalent as : round(months_between(date2, date1)/3)

But this will not work for particular data, since the logic in which SQL Server executes the DATEDIFF is different as I have explained above. Please can anyone give the exact equivalent if any available.

Thanks,
Sam




Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2005
Added on Jul 4 2005
2 comments
2,321 views