Want to check today date in If condition

Hi,

I am getting date in August,28,2020 format from web. My requirement is to check today date in if condition. If today date match then system execute further step.
I am getting date on web in August,28,2020 format. How i validate.

1 Like

I used below expression both are not working.
DateTime.ParseExact(TodayDate,“MMMM,dd,yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“dd-mm-yyyy”)

System.DateTime.Now.ToString(“MMMM,dd,yyyy”)

Working fine guys my mistake.

You will want to compare the dates as DateTime types and not as strings, just as a best practice.

Also, you can use Today for today’s date in the comparison

For example,
DateTime.ParseExact(TodayDate,“MMMM,dd,yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo) = Today

Notice how I left off the .ToString() parts in the comparison.

You can use the .ToString() part when you want to output the value or store it somewhere in a specific string format.

Regards.

  • Make sure you mark either your previous post or this post as the solution :slight_smile: