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
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
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)
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")
MyDateVariable is you variable that hold date [Ex: MyDateVariable = “2024-10-28”]
System.DateTime.Now gives us the current Date Time
We compare both and return the string from above example
Thanks,
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.