Question on filter datatable based on date

I have a datatable populated from a page. I build a datatable after selecting correct data types for rows and then used this as the output var for extracting data. Datatable has a datetime column to store the date from excel. I am trying to filter rows based on a date like below

dt.Select("[Date]>’"+DateTest+"’").CopyToDataTable

DateTest holds the value ‘2020-02-01’. I am getting the correct results ,ie, i am getting all rows after 1st Februrary 2020.

My doubt is whether this is the right way to compare as in other languages we normally convert the string to the date format and then compare… Here i have compared a string with date, hence the confusion.

Please help.

1 Like

@newuser29 This case which you have done has probably worked because the datetime format you are extracting from excel. it is best preferred to convert the string to date time before comparing. :slight_smile:

2 Likes

I assume same is the case with int32 types also

yes exactly @newuser29.