How to Convert Scrapped DataTable Column datatype from String to DateTime

Hi All,

Whenever i scrape any table from webpages, all the columns of the Datatable are of datatype string.
Now, Even the table contains Date or Datetime as one of the columns.

So how can i directly convert the Datatype of these date or datetime columns to datetime within the ExtractedDataTable.

I need to Filter the records based on date condition, like take only records which are created 7 or less days ago.

So if I need to filter the data, I can’t simple filter based on string as the string comparison with date is not consistent as well as Filtered data is not correct many time.

WorkAround I tried: Created a New Datatable (FinalDT) using Build DataTable with the column datatypes i need.
use a for Each activity and loop through the Extracted Datatable.
use an Add Data Row activity to add data into a FinalDT, use ExtractedDatatable row values and Convert the String values to Datatime.
Use Filter Datatable activity to filter the data from FinalDT based on date conditions.
Use FinalDT records to loop through further activities.

Any other option or direct conversion or workaround, please share it with me as its a long process and needs a lot of coding.

Waiting for your responses on the same.

Anil Kumar

This can be done even without changing the datatype if the column buddy

Kindly have a view on this pls

Cheers @Anil_choudhary

Will check it thanks

1 Like

Cheers @Anil_choudhary

@Palaniyappan i have same issue, i used your solution, i m facing this:
The only difference is that im using a csv file and not excel.
I have attached the csv file, as the zip file. (203 Bytes)

I have an option to use for loop and assign as below:
Datetime.parseexact(“date column”).ToString,“yyyyMMdd”,system.globalization.cultureinfo.invariantculture).ToOADate.ToString

However i was wondering if there is a faster and smarter way ?



I have same problem with you.Could you explain me to the solution you mentioned?