Hi All,
Can you please guide me on how to split the below datetime column to date and time separately.
PFB examples
INPUT DATE TIME OUTPUT DATE OUTPUT TIME
Sep 14, 2023 9:00 AM 20230914 090000
Sep 14, 2023 10:00 AM 20230914 100000
Sep 20, 2023 10:00 PM 20230920 220000
@aishwarya.srinivasan
can you share the input and expected output
cheers
ppr
(Peter)
September 19, 2023, 12:20pm
3
we would parse the string within a datetime and using toString(“FORMATSTRING”) to get it reformatted as we do need
Samples:
And
the above doesn’t work on both the below scenarios
Sep 14, 2023 9:00 AM
Sep 14, 2023 10:00 AM
the time is h:mm in one case and hh:mm in another
how to handle this?
ppr
(Peter)
September 19, 2023, 12:29pm
5
Parvathy
(PS Parvathy)
September 19, 2023, 12:35pm
7
Hi @aishwarya.srinivasan
Try this:
row("Date") = DateTime.ParseExact(datetimeValue, "MMM dd, yyyy h:mm tt", CultureInfo.InvariantCulture).ToString("yyyyMMdd")
row("Time") = DateTime.ParseExact(datetimeValue, "MMM dd, yyyy h:mm tt", CultureInfo.InvariantCulture).ToString("HHmmss")
Hope it helps!!
1 Like
ppr
(Peter)
September 19, 2023, 12:40pm
8
Kindly also note about combining different formats to get parsed it in one go:
Ensure:
1 Like
system
(system)
Closed
September 22, 2023, 12:40pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.