How to Convert String To Date Time – UiPath

In this module, we will we looking into different DateTime Manipulations
1.Converting String to DateTime Datatype 2.Converting Date from one String format to another desired format 3.Adding Hours, Minutes and Seconds to your Date
Note: In case you’re trying to convert DateTime Datatype to String, Click here

1.Converting String to DateTime Datatype

Implementation using UiPath : Let us implement a workflow that takes a string and converts it to DateTime Datatype. Step 1: Drag “Assign” activities into the designer panel and assign the string value and the format of DateTime. Use the “Write Line” activity to display the result. Example: If your input is like 19/09/2019 your format should be dd/MM/yyyy… If your input is like 2019/09/19 then your format should be yyyy/MM/dd…
output_date=DateTime.ParseExact(input_date,formatconversion,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
Excel_cultDateTime_image1Excel_cultDateTime_image2

2.Converting Date from one String format to another desired format

Implementation using UiPath : Let us implement a workflow that takes a Date string and converts it to another format. Example: If your input is like 19/09/2019 i.e.dd/MM/yyyy format, then you can convert it to another format like yyyy/dd/MM Step 2: Drag “Assign” activities into the designer panel and assign the string value and the format of DateTime. Use the “Write Line” activity to display the result.
output_date1=DateTime.ParseExact(input_date, “yyyy/MM/dd” , System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy/dd/MM”)
Excel_cultDateTime_image3Excel_cultDateTime_image4

3.Adding Hours, Minutes and Seconds to your Date

You can have the time along with your date Just add hh:mm:ss to the above… For 12 hour format, it is hh:mm:ss For 24 hour format, it is HH:mm:ss Excel_cultDateTime_image5Excel_cultDateTime_image6 Click here to download the Source Code… Hope it has helped you…

Leave a Reply

%d bloggers like this: