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!

Oracle SQL - Calculate Fiscal Week of Year

User_DY5EHJan 26 2023

I want to calculate the Fiscal Week of the Year with the following rules:
The fiscal year always starts on June/01
The week always starts on Sunday
Samples are provided for 2019 but ideally it should work for any year
As a reference 2019-06-01 would be the only day of the 1st fiscal week of that year, 2019-06-02 would be the first day of the 2nd week of the year as it's a Sunday
A few samples of correct values are provided with the screenshot attached
I tried to do something like TO_NUMBER(TO_CHAR(TO_DATE(DATE_ID + 1,'DD-Mon-YY'),'IW')) -21 but towards the end of the Calendar year I start to get negatives
image.pngimage.png

This post has been answered by Frank Kulash on Jan 26 2023
Jump to Answer
Comments
Post Details
Added on Jan 26 2023
5 comments
1,653 views