How to get previous month of the given input

input-> 09/07/2021
output → Aug-21

I want previous month name by given input.

Hey,
Could you try this ?
DateTime.Now.AddMonths(-1).ToString(“MMM-yy”)

1 Like

its taking the system date,
but here we have to take date in input variable,

Ok. So use this one:
Convert.ToDateTime(“09/07/2021”).AddMonths(-1).ToString(“MMM-yy”)
instead: “09/07/2021” you can use your variable of string.

1 Like

thankyou

you’re welcome :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.