Previous Year Fiscal Month End Date based on current selection
I have a requirement that needs to display Previous period end date for current selection (Fiscal calendar). A fiscal period will start last week of every month i.e Period December 2016 has started on 11/28/2016 but ends in December last week and Period January 2017 has started on 12/24/2016, ends in January last week etc.
For example, if I select a date 12/15/2017 in the date field, the previous year period end date will be an end date of the same month (i.e Dec)) in the year 2016 (like last year fiscal month end date was 12/22/2016), same way, if I select 1/13/2016, it should display end date of currently selected the month in the previous year (i.e 1/27/2015). It would differ for different periods.
Can anyone help me to get the calculation in script level.