Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to do the following and am unable to figure it out. Does anyone know how I can achieve this?
Goal
I have 2 fields: Year and Month_Nbr. In the end, I want them concatenated into the format 'yyyymm'. However, I need it to display 1 month prior to its value.
For example, 201902 would display as 201901; and 201901 would display as 201812; meaning the year would also need to decrease by 1 if the month is January.
This is the formula I came up with, which doesn't work because it reduces the year by 1, not the month.
Date(AddMonths(Date#(Num(Year) & Num(Month_Nbr,'00'),'yyyymm'),-1),'yyyymm')
These are the steps I took:
Result: 201902 becomes 201802
Desired: 201902 should become 201901
Any guidance is appreciated, thank you.
I think you might have missed the trick by using mm instead of MM. M is for Month and m is for minutes
Try this
Date(AddMonths(Date#(Num(Year) & Num(Month_Nbr,'00'), 'YYYYMM'), -1), 'YYYYMM')
I think you might have missed the trick by using mm instead of MM. M is for Month and m is for minutes
Thank you, that did it!