DateTime Operations in UiPath

DateTime Formats and Conversions in UiPath

In this article you will find all that you need to work with DateTime Formats and conversions.

Examples for different formats in UiPath

Example 1:

Input:
image

Output:

Example 2:

Input:
image

Output:
image

Example 3:

Input: Current system date

image

Output:
image

Example 4:

Input: Current system date

Example 4:

Input: Current system date

image

Output:

image

Example 5:

Input: Current system DateTime with Time zone

image

Output:

Uploading: image.png(2)…

Example 6:

Input: System DateTime which displays AM or PM

image

Output:

image

DateTime Properties:

There are several properties like Day, Month, Year, Hour, Minute, Second, DayOfWeek and others in a DateTime object which can be retrieved.

Example1:

Input:

image

image

Output:

image
image
image

Adding DateTime:

Below are the methods available in UiPath for adding DateTime:

image

Example1:

Input:

inputDate=”4/22/2020 3:30:20”

Convert.ToDateTime(inputDate).AddMonths(3).ToString(“MM”)

image

Output:

image

Subtracting two Dates:

Example1:

Input:

inputDate = “10/22/2020 3:30:20” or Convert.ToDateTime(“10/22/2020 3:30:20”).ToString(“MM”)

CurrentDate= Now.ToString or Convert.ToDateTime(Now).ToString(“MM”)

Subtracting two Dates:

Example1:

Input:

inputDate = “10/22/2020 3:30:20” or Convert.ToDateTime(“10/22/2020 3:30:20”).ToString(“MM”)

CurrentDate= Now.ToString or Convert.ToDateTime(Now).ToString(“MM”)

image

Output:

convert.ToDateTime(inputDate).Month-convert.ToDateTime(Now).Month

or

Convert.ToInt32(inputDate)-Convert.ToInt32(currentDate)

image

Example2:

Input:

inputDate and currentDate of type System.DateTime

image

image

Output:

2 Likes