Hi. How do I get the last month and year given current month
eg i have 11 january 2021
how do i get output december 2020
and if i have 1 feb 2021 i should get january 2021
Hi,
I think You could use the Built-in functions for that, like this:
AddMonths(YOURDATE,-1) - this will give the YOURDATE minus one month.
Kind Regards,
Ivan
nice:)
Hi again. Thank you for the solution. Sorry to bother, what if i want to get the last day of the current month?
Hi Rudo,
Try with this to get last day of current month:
AddDays( AddMonths( NewDate( Year(CurrDate()), Month(CurrDate()), 1 ), 1 ), -1 )
thank you so much for your quick reply
You'd use the AddMonths() built-in Function, with a second parameter of -1, so it gives you the previous month.
AddMonths(YOURDATE,-1) function will give you date with day count also but in your use case it shows that you don't want day count to be displayed.
To fix this, you need to use AddMonths function with proper date format as below:
FormatDateTime(AddMonths(YOURDATE,-1),"MMMM yyyy")
Hope it helps, Thanks :)