I have to compare datatable date column with todays date

Hi All,

I have to compare datatable date column with todays date.
Initially assigned datenow as Now , here datenow is datatime

in_dt_FilteredCGRecords.AsEnumerable.Where(Function(x) x(“Close Date (Expected Signing or Date Won/Lost/WD)”).ToString < datenow.ToString(“MM/dd/yyyy”)).Count

this condition is not satisfying. can anyone help on this.

Regards
Saranya A

Hi @saranya_asokan ,

For comparing dates you need to convert them. Please use the function as below
in_dt_FilteredCGRecords.AsEnumerable.Where(Function(x) Date.Parse(x(“Close Date (Expected Signing or Date Won/Lost/WD)”).ToString) < datenow).Count

If the format of date is not in standard format in your datatable then try using Date.ParseExact(<DateString(11/04/2022 11:22:22)>,“<Format of date String(MM/dd/yyyy hh:mm:ss)>”,System.Globalization.CultureInfo.InvariantCulture) instead of Date.Parse

This should solve you issue . Please let us know if you need further help

cheers

1 Like

Hi Anil_G,

Thanks for your timely help.

in_dt_FilteredCGRecords.AsEnumerable.Where(Function(x) Date.Parse(x(“Close Date (Expected Signing or Date Won/Lost/WD)”).ToString) < datenow).Count

This one is working fine. Thank you.

Hi @saranya_asokan ,

Do Close the Topic by marking the appropriate post as the solution and if your query has been resolved. It would benefit others who are in search for a similar solution.