ranjani
(Phoenix)
February 16, 2021, 12:44pm
1
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’")
Sugumar8785
(Sugumar Ramachandran)
February 16, 2021, 1:48pm
2
Do you want to add literal T and Z into the DateTime Variable?
ranjani
(Phoenix)
February 16, 2021, 3:30pm
3
20191208000002.804 to this format2019-12-08T00:00:02.804Z
@ranjani … Try like this…
ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”))
@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
Output:
Hope this helps…
2 Likes
ranjani
(Phoenix)
February 17, 2021, 11:17am
6
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
Manish540
(Manish Shettigar)
February 17, 2021, 11:31am
7
Check this below code, @ranjani
CDate(“02/08/2021 16:00:02”).ToString(“yyyy-MM-ddTHH:mm:ss.fffZ”)
Hope this may help you
1 Like
ranjani
(Phoenix)
February 17, 2021, 12:45pm
8
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?
Manish540
(Manish Shettigar)
February 17, 2021, 12:50pm
9
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??
ranjani
(Phoenix)
February 18, 2021, 3:33am
10
Manish540:
02/08/2021 16:00:02
02/08/2021 16:00:02 this is the value
prasath17
(Guru)
February 18, 2021, 3:47am
11
@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”))
Output
ranjani
(Phoenix)
February 18, 2021, 6:23am
12
prasath17:
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
system
(system)
Closed
February 21, 2021, 6:23am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.