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!

Fastest comparison of part of date

Heidi WeberMar 26 2014 — edited Mar 27 2014

Hello,

i have two tables with a date column, where i want to join. I need in the comparison onle the year and not the complete date.

What is the fastest method to compare only the year of the two date columns?

Must i convert the date column to a char YEAR? Something like that:

select c1, c2 from tab1 t1, tab2 t2 where to_char(t1.c1,'YYYY') = to_char(t2.c2,'YYYY')

Or is there a better method for that - e.g. not to convert the date to a char but to a number??? In other programming languages converting to a number and make the comparison is normally faster - isn“t it?

Thank you very much

Best reagrds

Heidi

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2014
Added on Mar 26 2014
5 comments
410 views