Skip to main content

Methods for DateTime variables

Suggest edit Updated on November 10, 2021

Methods for DateTime variables enable manipulation of dates within your automations.

Methods

MethodDescriptionParametersResult type
AddAdds timespan to the variable and returns the variable DateTime value.TimeSpanDateTime: Returns an object whose value is the sum of the date and time represented by this instance and the time interval.
AddDaysAdds days to the variable and returns the variable DateTime value.DoubleDateTime: An object whose value is the sum of the date and time represented by this instance and the number of days added.
AddHoursAdds hours to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time represented by this instance and the number of hours added.
AddMillisecondsAdds milliseconds to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time plus the milliseconds added.
AddMinutesAdds minutes to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time plus the minutes added.
AddMonthsAdds months to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time plus the months added.
AddSecondsAdds seconds to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time plus the seconds added.
AddTicksAdds ticks to the variable and returns the variable DateTime value.DoubleDateTime: The sum of the date and time plus the ticks added.
CompareTo

Compares the value of this instance to a specified DateTime value and indicates whether this instance is earlier than, the same as, or later than the specified DateTime value.

Enumeration is BeforeDate2, EqualToDate2, AfterDate2, Invalid.

DateTimeInt32: A signed number indicating the relative values of this instance and the variable.
EqualsReturns a value indicating whether two DateTime instances have the same date and time value. DoubleBoolean: Returns True if the two values are equal.
NowGets a DateTime object that is set to the current date and time on this computer, expressed as the local time.NoneDateTime
ParseConverts the string representation of a date and time to its DateTime equivalent. String: the date and time to convertDateTime
ParseExact

Converts dates that are in a string format and are formatted for another culture into a DateTime. For example, you can convert a date in dd-mm-yyyy format to a DateTime by specifying the format parameter.

This method converts the specified string representation of a date and time to its DateTime equivalent using the format and culture, or locale, information that you specify. The format of the string representation must match the specified format exactly.

You can define the culture parameter by selecting the locale from a list or entering it, such as en_us for US English or fr_ca for Canadian French.

input, format, culture DateTime
ResetStateResets all component properties to their initial values.
SubtractReturns the result from subtracting the specified time or duration from the value of this instance. DateTimeTimeSpan: Interval equal to the date and time of this instance minus the date and time of the variable.
TodayGets the current date.NoneDateTime
ToLongDateStringConverts the value of the current DateTime object to its equivalent long-date-string representation. String
ToLongTimeStringConverts the value of the current DateTime object to its equivalent long time string representation. String
ToShortDateStringConverts the value of the current DateTime object to its equivalent short date string representation. String
ToShortTimeStringConverts the value of the current DateTime object to its equivalent short time string representation. String
ToStringConverts the value of the current DateTime object to its equivalent string representation.

String

IFormatProvider

String: the value of the current DateTime object as specified.
TryParse Performs the TryParse action. If True, assigns the value to the variable and then outputs that value.
UtcNowGets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC). NoneDateTime
WeekOfYearGets the week of the year component of the date for the input value. DateTime Value Int32
Did you find this content helpful? YesNo

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us