Convert string of "DD-MMM-YYYY" to datetime and find difference

How to convert “24-JAN-2024” to datetime and find difference between it and current date?

Hey!

If Your input date is → “24-01-2022”

Try like this

Cdate(Input).ToString("dd-MMM-yyyy")

If you wants to find the difference between the dates:

DateDiff(DateInterval.Day, DateTime.ParseExact(Input.ToString, "dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture),DateTime.now())

Try this and let me know

Regards,
NaNi

we can parse the string into a DateTime with the help of ParseExact
grafik
myDate = DateTime.ParseExact(strDateVar, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)

then we can subtract the date from Now.Date which is similar to Today and will get back a TimeSpan
grafik

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