I’m reading a date data from excel file and I got random number as output. I tried this expression but it’s throwing me this error :
date_auction_tmp = DateTime.FromOADate(Double.Parse(row.item(8).ToString))
date_auction_tmp is string type variable
How to solve it? Thanks
@Rhys18 Try below solution
DateTime dt = DateTime.FromOADate(row.item(8).ToString)
Check the date_auction_tmp data type it should be DateTime Type
Changing from string to date time is working but other variable is having errors. Can it just be string var only?
This is throwing me error @THIRU_NANI
Could you please show us the value on which you are trying for conversion?
Could you please provide us the input data?
Yes. Sure, Let me share it here.
I have a a data like this :
As it can be see, there’s a cell with double value (with / on the cell). So I’m trying to convert it using FromOADate and I got result like this :
For some reason the date is read as a random number and I need to get the left cell value of the data. I tried to change the excel format date into MM/dd/yyyy but because I have use split(var_date), it only take the month.
What’s the current setting for Preserve Format please ?
Could you please try enabling it once and see if you directly get the date itself in the DataTable ?
Looks ike it is still coming as number only.
Please share the file here if possible without disclosing sensitive data.
Sure, here’s the data :
Auction date.xlsx (9.7 KB)
I hope you are reading the excel and trying to convert the value in excel to the datetime.
If you are reading the row it will be in string format, so you can watch the below video to convert it to datetime format.
Else you can use Modify date activity as well.
Please find the output with Preserve Format enabled,