How To convert csv number format to Date

image

HI, Team I have a column in the CSV file “CreatedDate” this have a Date value but in number format,

My below piece of code is not working, Could you please guide me what is the issue or any another way to convert this

CreatedDate
1,486,684,486,000
1,486,724,287,000
1,486,724,542,000
1,487,164,981,000

DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(CurrentRow.Item(“CreatedDate”).toString)).Date.ToString( “MM/dd/yyyy”)

image

@Techie_Talk_s

Welcome to the community

Can you try this please

DateTime.FromOdate(cdbl(numdate)).ToString("MM/dd/yyyy")

Cheers

Hi @Techie_Talk_s

Check below video for your reference

Hope this may help you

Thanks,
Srini

Hi @Techie_Talk_s ,

The Expression used should work, But Could you Check if the Long.Parse() works at first by performing a Debug ?

It does seem that the comma does get affected. However, Maybe try using Replace function to replace commas with empty string at first and we could understand if that is the real reason for the error. There might be empty values as well in the column which might give the error.
image

So, you could try using the below modified Expression :

DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(CurrentRow.Item("CreatedDate").ToString.Replace(",",""))).Date.ToString("MM/dd/yyyy")

Let us know if you could check the above expression.

Thanks Buddy ,
It works

1 Like

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