Convert Datetime to Date & Time columns

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

we would parse the string within a datetime and using toString(“FORMATSTRING”) to get it reformatted as we do need

Samples:
grafik

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?

We got it work:
grafik

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

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

Kindly also note about combining different formats to get parsed it in one go:

grafik
grafik

Ensure:
import_systemglobalization

1 Like

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