String was not recognized as a valid DateTime like "45175"

Hi all,

I read Excel file have D column Date format but when read is: 45175,45180,45181
I use some suggestions but not work. Can help me check, thank all

DateTime.ParseExact(ngayhd, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString

DateTime.ParseExact(in_PaymentStartDate.ToString, “dd/MM/yyyy”, nothing).toString(“dd/MM/yyyy”)

image

image

Hi @anh.nguyen ,
Check read range activity property
image
tick “PreserveFormat”
image
hope it help
regards,

Thank you,

When I check it show Date format but other column I use code as below, it = 0?
CDbl(Row(“column11”))*(-1)-CDbl(dtCRT001Inv.Rows(idxInv)(“Column11”))

Before I check “Preserve Format” can calculate formula
image

Can you share your original file and detail requirements?
Or you can try convert only columns date Cdate(row(yourcolumnsname).ToString(“dd/mm/yyyy”))
I think your file have valid format,

1 Like

Hi,

You can use the following expression to convert an Excel date value (e.g., 45175) to a formatted date string:

DateTime.FromOADate(CDbl(ngayhd)).ToString(“dd/MM/yyyy”)

1 Like

Hi

We have a knowledge base in UiPath forum on DATETIME

For your query

Convert a OADate in excel to a Datetime or string Datetime

Suppose Actual value being entered: ‘43800’ but the required value is “1-Dev-2022” in format “dd-MMM-yyyy”

Then use this in assign activity

str_datetime = DateTime.FromOADate(Convert.ToDouble(Strinput.ToString)).ToString(“dd/MM/yyyy”)

Have a view on this for all functions in Datetime

Cheers @anh.nguyen

1 Like

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