Is there a way to find out years and quarters based on a date range.
We are considering November as Start date and October as End date of financial year.
Ex: Nov prev Year to Oct next Year is considered as one financial year.
November 1, 2014 - October 31, 2015 - > It is considered as one financial year
Any record past Oct 31 will go to next financial year.
We also need to find Quarters as below
Quarter 1 = November, December & January
Quarter 2 = February, March, April
Quarter 3 = May, June, July
Quarter 4 = August, September, October
moment('2014-12-01').utc().quarter()
->
it returns 4 considering Jan as Start date of financial year.
But it is considered as 1st quarter.
-- Code --
function getQuarter() { var obj = {};
// Set Quarters form nov
obj.quarter1 = {start:Moment().month(10).startOf('month'),end:Moment().month(0).endOf('month').add(1,'years')};
obj.quarter2 = {start:Moment().month(1).startOf('month').add(1,'years'),end:Moment().month(3).endOf('month').add(1,'years')};
obj.quarter3 = {start:Moment().month(4).startOf('month').add(1,'years'),end:Moment().month(6).endOf('month').add(1,'years')};
obj.quarter4 = {start:Moment().month(7).startOf('month').add(1,'years'),end:Moment().month(9).endOf('month').add(1,'years')};
return obj;
}
have used this to set quarters starting from November.
Is there any alternative approach ?