How to convert DateTime variable to String in UiPath
Converting a DateTime variable to a string is the most important part of Automation.
How do we get the system date and time in UiPath?
By using the above syntax you will be able to get the date and time at that particular time.
How we convert this to string?
We need to add this at the end .ToString as shown below:
As of now, we converted a DateTime Variable to String. We now see how we can convert this into a different format.
What is the common DateTime format?
How we can change it to different format?
This will give us the date format as shown below
Changed Date Format : 02-11-2020
While automating different business processes may demand different time formats.
How we can make different datetime formats in UiPath?
You have to know how to differentiate between day, month, year, hour, minute, seconds by following the below letters.
- d -: Represents the day of the month i.e 1,2,16 or 31
- dd -: Represents the day of the month i.e 01,05,14 or 31
- ddd -: Represents the abbreviated name of the day i.e Mon, Tue or Wed
- dddd -: Represents the full name of the day i.e Monday, Tuesday or, Wednesday
- M -: Represents the month number i.e 1,5 or 12
- MM -: Represents the month number with leading zero i.e 04,09 or 12
- MMM -: Represents the abbreviated month Name i.e Jan, May, or Dec
- MMMM -: Represents the full month name i.e. January, June or, December
- y -: Represents the year i.e. 2019 as 19
- yy -: Represents the year with a leading zero i.e. 2019 as 019
- yyy -: Represents the year i.e 2019
- yyyy -: Represents the year i.e 2019
- h -: Represents the 12-hour clock i.e 4,11 or 2
- hh -: Represents the 12-hour clock with a leading 0 i.e. 04,05 or 12
- H -: Represents the 24-hour clock i.e 13,18 or 22
- HH -: Represents the 24-hour clock with a leading 0 i.e. 04,09 or 22
- m -: Represents the minutes i.e. 12,40 or 56
- mm -: Represents the minutes with a leading zero i.e 04,09 or 23
- s -: Represents the seconds i.e 9,35 or 40
- ss -: Represents the seconds with leading zero i.e. 04,09 or 35
By using these patterns we can easily get the DateTime in the required format.
That’s it for this post on DateTime Operations in UiPath.