Tuesday, 7 May 2013

Convert Date into Week Range


1). How to get week of the year?

SELECT to_char(sysdate,'WW') FROM Dual;


2). Now lets get Current week range?

SELECT    TO_CHAR (TRUNC (SYSDATE, 'IYYY') + ((TO_CHAR (SYSDATE, 'WW') - 1) * 7), 'DD-MON-RR')
       || ' to '
       || TO_CHAR (TRUNC (SYSDATE, 'IYYY') + ((TO_CHAR (SYSDATE, 'WW')) * 7)-1, 'DD-MON-RR')
FROM   Dual;

0 comments:

Post a Comment