How check 2024-10-28 date expired or not with current date

Hi all,

How check 2024-10-28 date expired or not with current date

My variable value: 2024-10-28

I have to check it expired or not with current date

thanks
shaik

@shaik.muktharvalli1,

Hold the string date value in a variable, then parse it to a date and assign it to a datetime variable. Then compare it with today’s date

DateTime.ParseExact("2024-10-28", "yyyy-MM-dd", CultureInfo.InvariantCulture)

Hi @shaik.muktharvalli1

I have sharing a Ternary Operator which is equavalent to If-Else condition

If(System.DateTime.ParseExact(MyDateVariable, "YYYY-MM-dd", Nothing) > System.DateTime.Now, "Then - Exceed", "Else - still your date is under the current date time")

  1. MyDateVariable is you variable that hold date [Ex: MyDateVariable = “2024-10-28”]

  2. System.DateTime.Now gives us the current Date Time

  3. We compare both and return the string from above example

Thanks,

Hi @shaik.muktharvalli1

Try this

DateTime.ParseExact(Input, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) < DateTime.Now.Date

Cheers!!

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