Date calculation to work out financial week number
Hi there,
I'm not skilled in javascripts so hope someone might be able to help me out here but I am basically trying to use a date calculation to work out the financial week number
eg, today 26/04/2016 is calendar week #17 but Australian financial week # 43 (I think)
I need to see how many items are due in that week I have my calendar due dates set up per itemt but need to report on them per financial week.
If anyone could help me out that would be wonderful.
Thanks
-
Hi Nicole,
Is July 1st always week #1 or can it be #52 (like in this year; July 1st is calendar week #26 - which # is financial week: 1 or 52?)
This would give you July 1st, 2016 = # 52:
var date = @Date A;
var dateY = moment(date).year();
var dateW = moment(date).isoWeek();
var finStart = moment(dateY +"-07-01","YYYY-MM-DD");
var finStartW = moment(finStart).isoWeek()
dateW < finStartW ? dateW+finStartW : dateW == finStartW ? dateW+26 : dateW-finStartW
And this July 1st , 2016 = financial week # 1
dateW < finStartW ? dateW+finStartW : dateW == finStartW ? dateW+26 : dateW-finStartW
Rainer
rg@delos-consulting.com -
Hi Nicole,
I've thought financial weeks in Australia follow the isoweek specifications, but it seems, they don't.
So this would give you the right result for:
Week #1 (2017) = Sunday 26th June - Saturday 2nd July.
Week #52 (2016) = Sunday 19th June - Saturday 25th June.var date = @Date A;
var dateW = moment(date).week();
dateW <= 26 ? dateW+26 : dateW - 26But for the next FY you'll get this:
Week #1 (2018) = Sunday 2nd July - Saturday 8th July
Week #52 (2017) = Sunday 25th June - Saturday 1st July.
If this is right you can use it. If the wanted result should be
Week #1 (2018) = Sunday 25th June - Saturday 1st July
Week #51 (2017) = Sunday 18th June - Saturday 24th June
you can use this:var date = @Date A;
var dateY = moment(date).year();
var dateW = moment(date).week();
var finStart = moment(dateY +"-07-01","YYYY-MM-DD");
var finStartW = moment(finStart).week();
+(dateW == "26" && finStartW == "26") || +(dateW == "27" && finStartW == "27") ? 1 : dateW <= 26 ? dateW+26 : dateW - 25Rainer
Please sign in to leave a comment.
Comments
7 comments