Filter using Date in DataTable

I need to extract datatable from a datatable - dt, where date is greater than 2 months.

I used the following query:
DateVariable => DateTime Variable

dt.AsEnumerable.Where(function(x) DateTime.ParseExact(x(“date”).ToString,“MM/dd/yyyy”,Nothing)<DateVariable)

Error: Option Strict on disallowing late binding.

Dt = dt.Select("[Date]>= now.AddMonths(2).ToString").CopyToDataTable() - try this once

@Altavista

Thanks!

its not accepting the date query. The expression contains undefined function call now.AddMonths()

Try this then…!

yourDt.AsEnumerable().Where(Function(row) datetime.ParseExact(row(“DateColumn”).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)>=now.AddMonths(2)).CopyToDatatable

@Altavista

Thanks!

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