Date to string conversion

Hi team,

Can anyone help me to solve error – string to type date conversion is not valid , generated through below statement

Dt.as enumerable.where(Function (x) CDate(x(date)) < DateTime.now.AddDays(-5)).CopyToDataTable

1 Like

Hey!

Try with parse exact method…

Regards,
NaNi

@Hitesh1 Try the below one with assign activity

Variable of type data table DT1 = DT.AsEnumerable.Where(Function(x) DateTime.ParseExact(x("Date").ToString, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")<Now.AddDays(-5).ToString("MM/dd/yyyy")).CopyToDataTable
  • DT is the data table contains the actual data
  • DT.AsEnumerable.Where(Function(x) DateTime.ParseExact(x("Date").ToString, "MM/dd/yyyy", here MM/dd/yyyy is the format that contains in data table. You can change this according to the format that your data table column has

Check attached workflow for ref

Example.zip (3.2 KB)