DateTime Formatting issue while reading the Excel


I have an excel which has a date time related column. When I read the excel the values are fetched in form of a string/double value having some random numbers like 43788.8488…

I tried to use FromOAdate for for matting the whole date column as well but then it gives an exception stating “input string was not in a correct format”.
The excel formatting is of the form as shown below.

dateChangeValue = DateTime.FromOADate(CDbl(row(“Verification Date”))) , this is how I have written the code.
I am iterating the same in a for each row.
Could anyone tell what is wrong in it?

this expression is actually correct
but i think the activity is taking the date value as it is
lets check that with a writeline activity where mention like this
row(“Verification Date”).ToString inside the for each row loop
lets see what value is coming in the output panel

Cheers @ashutoshkhantwal

1 Like

Hello Palani,
The formatting is of the form as visible on the image and it is coming as it is in the datatable as well.

Try to split the expression into two steps:
oaDate = CDbl(row(“Verification Date”))
dateChangeValue = DateTime.FromOADate(oaDate)

It will help you identify which conversion actually fails.



Hi @J0ska

Try Cdate(row(“Verification Date”).ToString(“dd/mm/yyyy”))

Ashwin S

Hi, Ashwin. The excel format for the cell/column is not helping the case and it won’t get converted to date using cdate() because the value read by the data table is some garbage value instead of the date value. Also I have kept keep formatting as checked while reading. Could that be an issue?

Will try with that. Thanks

I tried to simulate your business scenario.
1/ I made an excel with date column
2/ I read excel using ReadRange activity

and I am getting already a string value in the resulting datatable


So the whole conversion seems redundant and the following should be sufficient

dateChangeValue = CDate(row(“Verification Date”))


1 Like

I found out the issue why the code mentioned by you and myself wasn’t working. It was because there was a row which had a blank value for the date due to which it was giving an error “invalid string” . Just needed to delete that row and it worked.

Thanks everyone for their input.

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