Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Dates methods

Updated on October 19, 2022

Use the dates methods to use, extract, and evaluate dates in your automations.

Compare methods

MethodDescription
CompareCompares two instances of DateTime and returns whether the first instance is earlier than, the same as, or later than the second instance.
DateA new DateTime with the same date as DateTime value, and the time value set to 12:00:00 midnight (00:00:00).
EqualsReturns a value that indicates whether two DateTime objects, or a DateTime instance and another object or DateTime, have the same value.

Convert methods

MethodDescription
ParseConverts the string representation of a date and time to its DateTime equivalent.
ParseExactConverts the specified string representation of a date and time to its DateTime equivalent. The format of the string representation must match a specified format or an exception occurs.
TryParseConverts the specified string representation of a date and time to its DateTime equivalent and returns a value that indicates whether the conversion succeeded.

Extract methods

MethodDescription
DayGets the day of the month that is represented by this DateTime instance.
DayOfWeekGets the day of the week that is represented by this DateTime instance.
DayOfYearGets the day of the year that is represented by this DateTime instance.
DaysInMonthReturns the number of days in the specified month and year.
HourGets the hour component of the date that is represented by this DateTime instance.
IsDaylightSavingTimeIndicates whether this instance of DateTime is within the daylight saving time range for the current time zone.
IsLeapYearIndicates whether the specified year is a leap year.
MillisecondGets the milliseconds component of the date represented by this DateTime instance.
MinuteGets the minute component of the date represented by this DateTime instance.
MonthGets the month component of the date represented by this DateTime instance.
SecondGets the seconds component of the date represented by this DateTime instance.
TicksGets the number of ticks that represent the date and time of this DateTime instance.
TimeOfDayGets the time of day for this DateTime instance.
TodayGets the current date.
WeekOfYearReturns the week of the year that includes the date in the specified DateTime value.
YearGets the year component of the date represented by this DateTime instance.

Math methods

MethodDescription
AddReturns a new DateTime that adds the value of the specified TimeSpan to the value of this instance.
AddDaysReturns a new DateTime that adds the specified number of days to the value of this instance.
AddHoursReturns a new DateTime that adds the specified number of hours to the value of this instance.
AddMillisecondsReturns a new DateTime that adds the specified number of millieseconds to the value of this instance.
AddMinutesReturns a new DateTime that adds the specified number of minutes to the value of this instance.
AddMonthsReturns a new DateTime that adds the specified number of months to the value of this instance.
AddSecondsReturns a new DateTime that adds the specified number of seconds to the value of this instance.
AddTicksReturns a new DateTime that adds the specified number of ticks to the value of this instance.
AddYearsReturns a new DateTime that adds the specified number of years to the value of this instance.
SubtractReturns the value that results from subtracting the specified time or duration from the value of this instance.

Now methods

MethodDescription
NowGets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
UtcNowGets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).

String methods

MethodDescription
GetTimeStampReturns a formatted string with a timestamp. The default timestamp format is yyyyMMddHHmmssfff.
ToLongDateStringConverts the value of the current DateTime object to its equivalent long date string representation.
ToLongTimeStringConverts the value of the current DateTime object to its equivalent long time string representation.
ToShortDateStringConverts the value of the current DateTime object to its equivalent short date string representation.
ToShortTimeStringConverts the value of the current DateTime object to its equivalent short time string representation.
ToStringConverts the value of the current DateTime object to its equivalent string representation.

TimeZone methods

MethodDescription
ConvertTimeConverts a time to the corresponding time in the specified time zone.
ConvertTimeFromUtcConverts a Coordinated Universal Time (UTC) to the time in the specified time zone.
ConvertTimeToUtcConverts a date and time to Coordinated Universal Time (UTC).
FindTimeZoneInstantiates a new TimeZoneInfo object based on its identifier.
GetTimeZonesReturns a sorted collection of all the time zones about which information is available on the local system.
LocalTimeZoneGets a TimeZoneInfo object that represents the local time zone.
TimeZoneToStringReturns the display name of the current TimeZoneInfo object.

Have a question? Get answers now.

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

Did you find this content helpful?

Want to help us improve this content?

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