Can someone help me to minus the days from a given date

I need to minus the number of days from a date
Eg: x=7(number of days)
Date: 28-09-22

I need to get that in date format again

Can someone help me with this
Thanks

Hi @shilpa_p
Please Try This
YourDateTimeVariable.AddDays(-7).Tostring(“dd-MM-yy”)

1 Like

Thank you so much :). I shall try this

Yes Try this one
OR

If your variable is StringType then
DateTime.ParseExact(StringVariable,“dd-MM-yy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-7).ToString(“dd-MM-yy”)

1 Like

Hello @shilpa_p
Try with this one

DateTime.ParseExact(YourString,"dd-MM-yy",System.Globalization.CultureInfo.InvariantCulture).AddDays(-7).ToString("dd-MM-yy")

1 Like

Hello @shilpa_p

If you want to go with UiPath default activities instead of a line expression, you can use Modify Date activity.

How to Modify Date in UiPath? Modify Date activity explained with demo

Thanks

1 Like

Thanks everyone for the response :slight_smile:. I will try all these