I need to count a continuous number of weeks between two dates, at the moment I can partially do this using
select
(next_day(TO_DATE('01-01-1994', 'DD/MM/YYYY'), 'MONDAY')-next_day(TO_DATE('01-01-1995',
'DD/MM/YYYY'), 'MONDAY'))/7 countinous_weeks
from dual;
I get 52 weeks between the two dates, but when I check the last week of '01 -01-1994 ', I get 53 weeks.
select
to_char(TO_DATE('31-12-1994', 'DD/MM/YYYY'),'ww') as last_week_test
from dual;
It’s obvious enough to understand why this is happening, but I would appreciate it if someone could come up with a way to count the number of weeks continuously without using next_day, because that is where I think the problem is.
Thanks so much for any advice in advance.
source
share