How to get two previous months

Hi, please can anyone help me?
How can i get two previous months, when i use “new DateTime(now.Year,now.Month-2,1).ToString(“dd.MM.yyyy”)” but it doesn’t work (error Year,month and day parameters describe an un-representable Datetime).

@Hozy

Welcome to our uipath community.

Try this.

           Now.AddMonths(-2).Tostring("dd.MM.yyyy")
2 Likes

@lakshman
new DateTime(now.Year,now.AddMonths(-2),1).ToString(“dd.MM.yyyy”)
error: value of type ‘date’ cannot be converted to ‘integer’.

@Hozy

Have you tried above mentioned expression ?

@lakshman

it works ! Thank you!

1 Like

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