Convert dd/MM/yyyy HH:mm:ss to 'yyyy-MM-dd'T'HH:mm:ss.fff'Z'

I have a column to be converted from dd/MM/yyyy HH:mm:ss to ‘yyyy-MM-dd’T’HH:mm:ss.fff’Z’. I tried below code but no changes happens.How can we convert it

date.ParseExact(row(0).ToString,“dd/MM/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd’T’HH:mm:ss.fff’z’")

Do you want to add literal T and Z into the DateTime Variable?

20191208000002.804 to this format2019-12-08T00:00:02.804Z

@ranjani … Try like this…


@ranjani - Check this below workflow…

Build Datatable

Invoke Code

dtSample.AsEnumerable().ToList().ForEach(Sub(row) row(“DatefffZ”)=DateTime.ParseExact(row(“DatefffZ”).ToString,“yyyyMMddHHmmss.fff”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”))

Invoke Code Edit Arguments



Hope this helps…


Thanks for your inputs but what if my input is in this format 02/08/2021 16:00:02?
i tried T and Z without quotes for this format but didn’t work

Check this below code, @ranjani
CDate(“02/08/2021 16:00:02”).ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”)
Hope this may help you :slight_smile:

1 Like

Thanks for input.It works if i pass direct date,but it didn’t work if i pass below in for each CDate(row(0).ToString).ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”)

i think its because passing a string.Is there a way to pass the row value?

Use row(0).ToString.Trim in above code and check, sometimes whitespaces may cause the problem @ranjani , and
What is the value of row(0).ToString??

02/08/2021 16:00:02 this is the value

@ranjani - You could have easily adjusted the code which i have provided…

dtSample.AsEnumerable().ToList().ForEach(Sub(row) row(“DatefffZ”)=DateTime.ParseExact(row(“DatefffZ”).ToString.Trim,“MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”))


Yeah did the same and worked.Sorry for late update.Thanks for your help.

1 Like

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