How to get the complete 2 months old date?

hello,
I am trying to get the date 2 months old date. so how can i get it? My date is 7/1/2021 now i need to get 2 months prior date to this date. Kindly help me to solve my issue.

Hi @sneha_arbole

Try this : Now.AddMonths(-2).ToString("dd/MM/yyyy")

For the date mentioned by you, use this-

Date.Parse("7/1/2021", New System.Globalization.CultureInfo("en-IN")).AddMonths(-2).ToString("%d/%M/yyyy")

the date format is mm/dd/yyyy. i tried changing the format but getting wrong output

Date.Parse("7/1/2021").AddMonths(-2).ToString("%M/%d/yyyy")

Thank you verymuch. it worked.

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