How to properly convert Date from excel to String?

Hi all,

I have a column Date Time that I need to convert later on to String.

dateTeime

As you can see from the screenshot, when I select a particular cell from the Date Time column(35:36.3), in the format field above you can see it’s different - 12:35:36 AM.

The first question is why is that happening? I assume the proper format is 12:35:36 AM but still don’t understand why are cells populated with these odd format - 35:36.3

Second thing I don’t understand is:
In the code, there is an assign dateTime = row(“Date Time”).ToString. Output for this assign is 44483 which is very weird.

Any thoughts on how I should get the correct dateTime?
Thanks in advance. :raised_hands:

1 Like

string contains the milisecond fractions
grafik

or getting it as a timespan:
grafik

DateTime.FromOADate(44483) will do it
grafik

1 Like

Hi

May be let’s go one by one

Here the format is changing so as the column format in excel
That specific excel column has a different format
I would suggest to make it as TEXT so that we won’t face this format change issue

And for this

If it is Text format in excel then this issue won’t come
As it is of different format it’s getting changed

In that case either we choose PRESERVE FORMAT in READ RANGE activity to get the formar as it is

Or

If it’s not working then once after getting the output like this 44483

Then use a Assign activity like this to get the value you want

Stroutput = DateTime.FromOADate(Convert.ToDouble(row(“yourcolumnname”).ToString)).ToString(“dd/MM/yyyy”)

This will give as the datetime in string format
You can change format you want

Cheers @bp777

1 Like

Hi @bp777

Its a of Type OA date format.

refer the thread below!

Regards

1 Like

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