I have Past date in variable and that needs to subtract like (-1) day

I have Past date in variable like (Nov-03-2024) and that needs to
subtract like (Nov-02-2024) day, kindly check and help on this

Use this expression

Cdate(SomeDate).AddDays(-1).ToString(“MMM-dd-yyyy”)

Hi @venkatreddy

Use the below expression to subtract one day from the given date.

- Assign -> InputDate = "Nov-03-2024"
- Assign -> YesterdayDate = DateTime.ParseExact(InputDate.toString, "MMM-dd-yyyy", System.globalization.Cultureinfo.invariantculture).adddays(-1).toString("MMM-dd-yyyy")

Check the below workflow screenshot for better understanding,

Hope it helps!!

@venkatreddy,

1. Parse the dates:

date1 = DateTime.ParseExact("Nov-03-2024", "MMM-dd-yyyy", Globalization.CultureInfo.InvariantCulture)
date2 = DateTime.ParseExact("Nov-02-2024", "MMM-dd-yyyy", Globalization.CultureInfo.InvariantCulture)

2.Calculate the difference:

dateDifference = DateDiff(DateInterval.Day, date2, date1)

hey @venkatreddy use this expression,

DateTime.ParseExact(strYOurDate, “MMM-dd-yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“MMM-dd-yyyy”)

cheers

Thank you All for immideate responses, it’s working fine now…

Make the post which helps you get solution, Mark it as solution to close the loop and it will helpful for the folks who are searching for the same query… @venkatreddy

Happy Automation!!