By your definitions, the 1st Saturday of a quarter will be on the 1st of a month; on the 31st, 30th, 29th, 28th, 27th, or 26th of the previous month if it has 31 days; or on the 30th, 29th, 28th, 27th, 26th, or 25th of the previous month if it has 30 days. Therefore, the last Saturday of a quarter will be on the 25th, 24th, 23rd, 22nd, 21st, 20th, or 19th of a 31 day month or on the 24th, 23rd, 22nd, 21st, 20th, 19th, or 18th of a 30 day month. So, the code you're using in the
GetFirstLastWeek() function might work for certain quarters of certain years, but it can't provide the correct results for the general case.
What are the English definitions of what is to be printed in your output following the text:
- ALLC_CurrentWeek,
- ALLC_CurrentPeriod,
- PriorQuarterAD,
?
You didn't show us the source for the script
/home/oracle/Hyperion_Batch/Scripts/Batch/_env.sh. How does it set the values for the variables
_YEAR,
_MONTH, and
_DAY? Are they the calendar date on which the script is run? (If so, many of your calculations will be wrong. If you had run this script on 12/31/2016, your script would be trying to find dates based on
FY4Q2016 instead of
FY1Q2017.)
How have you tested this code to verify that the results produced are correct when run in the 1st and last week in a quarter where the calendar month and calendar year match the fiscal year and fiscal month (in one case) and where the calendar and fiscal month and year are different? (You might consider having your script look for a single command-line argument. If it is found, use that argument as the current date instead of using the actual current calendar date. That will allow you to see if you get what you want on any date you want to try past, present, or future. Otherwise, use the current date like your script does now.)