Can you please guide me on how to split the below datetime column to date and time separately.
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
can you share the input and expected output
we would parse the string within a datetime and using toString(“FORMATSTRING”) to get it reformatted as we do need
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?
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!!
Kindly also note about combining different formats to get parsed it in one go:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.