Date conversion issue using uipath

read range only but we cant check the preserve format option

Have you tested:

DateTime.FromOADate(41397).ToString("dd/MM/yy hh:mm:ss")

Okay can you try with reading the specific column

Then try to work on the values

tried
the string is being stored as a 5 digit numeric value
and then the conversion doesnt work

@shilpashree.mohanty ,

Can you share a snap of the expression and flow.?

If you are having the value read from excel as string then replace yourExcelDate as Cint(yourExcelDate)

In the provided expression and try.

unable to convert string to double

have an example on a cascade to handle different scenarios

and feel free to adapt it to your scenario also by decomposing the LINQ to essential activities

Hi @shilpashree.mohanty ,

Check the flow attached in the other thread you had created.

Thanks,
Gautham.

Use CDbl to convert to double.

DateTime.FromOADate(CDbl("41397")).ToString("dd/MM/yy hh:mm:ss")

getting this error,

@shilpashree.mohanty Put this:

CDate(DateTime.FromOADate(CDbl(batchDateString)).ToString("MM/dd/yyyy hh:mm:ss"))

OR This:

DateTime.FromOADate(CDbl(batchDateString))

Regards,
Ajay Mishra

second one works but output is in MM/dd/yyyy format

What is the type of the variable your are trying to assign the value to? If it’s DateTime, then skip the ToString() part.

yourDateVariable = DateTime.FromOADate(CDbl(batchDateString))

The expression I provided you returns a string:

if i skip toString part its coming in MM/dd/yyyy format

@shilpashree.mohanty Correct, Let me tell you UiPath by default DateTime format is MM/dd/yyyy only means firstly Month then date then year!

If you need Date first then you have to convert value in string format,

DateTime.FromOADate(CDbl(batchDateString)).ToString("dd/MM/yyyy hh:mm:ss")

Note Above query output will be String. So, In Assign left side vairable type should be String not Date.

Regards,
Ajay Mishra

If you skip the ToString() part, you will need to call it later when converting to a format you want.

yourDateVariable = DateTime.FromOADate(CDbl(batchDateString))
newformatDateString = yourDateVariable.ToString(“dd/MM/yy hh:mm:ss”)

cant this be converted to date variable

the final output should be date type - dd/MM/yyyy

@shilpashree.mohanty Nope it’s not possible, can you tell me why you want the value as date type?

Regards,
Ajay Mishra

to be printed in another excel