Search This Blog

Total Pageviews

Tuesday, 6 December 2011

How to calculate week in oracle

Oracle week calculate 


calculate week


 


SQL> select  abs(to_number(to_char(to_date('21-oct-2011','dd-mon-yyyy'), 'WW')) - to_number(to_char(to_date('06-dec-2011','dd-mon-yyyy'),'WW')) ) "No of weeks" from dual ;

No of weeks
-----------
          7


 


 


 


SQL> select abs(to_number(to_char(to_date('21-oct-2011','dd-mon-yyyy'), 'WW')) - to_number(to_char(to_date(sysdate,'dd-mon-yyyy'),'WW')) ) "No of weeks"
from dual ;


 


No of weeks
-----------
          7


No comments:

Oracle DBA

anuj blog Archive