I need to get previous month from today’s date
For example
Today’s date:12/15/2022
My output should be:11/15/2022
Another example:
Consisder Today’s date:01/15/2022
My output should be:12/15/2021
I need to get previous month from today’s date
For example
Today’s date:12/15/2022
My output should be:11/15/2022
Another example:
Consisder Today’s date:01/15/2022
My output should be:12/15/2021
Hi @sruthesanju
Please try this function to get the date.
today = DateTime.Now
prevMonth = today.AddMonths(-1)
HI @sruthesanju
Another Method is like you can pass your input string into the expression like in the image
DateTime.ParseExact("01/15/2022","MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddMonths(-1).ToString("MM/dd/yyyy")
Here Now.addmonths(-1)
will give the only the previous month date not your required output
Regards
Gokul
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.