Exception: Conversion from string \"dd/mm/yyyy\" to type 'Date' is not valid.",

Hi.

I am stuck with a basic dates comparisons.

I want to see if a given date is greater than 6 months

entryDateDate = DateTime.ParseExact(entrydate, “dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

TodaysDate6MonthsAgoDate = DateTime.ParseExact(Now.AddMonths(-6).ToString(“dd/MM/yyyy”), “dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

if entryDateDate > TodaysDate6MonthsAgoDate
//Greator than 6 months

However, i keep getting **Exception: Conversion from string "14/06/2021" to type ‘Date’ is not valid.". Can some one assist with what i am doing wrong here?

Hi @sacad

If you re reading date value from excel the below will work!

DateTime.ParseExact(row("columnname “).ToString.Substring(0, 10),“dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).toString(“dd/MM/yyyy”)

For Second expression!

Now.AddMonths(-6).ToString(“dd/MM/yyyy”) is enough!

Regards

ensure that your variable datatype is configured to the following:
grafik