Skip to main content


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

TimeSpan methods

Updated on October 19, 2022

Use TimeSpan methods to extract, use, and evaluate intervals of time in your automations.

Compare methods

MethodDescription
CompareCompares two TimeSpan values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.
EqualsReturns a value that indicates whether two instances of TimeSpan are equal.

Convert methods

MethodDescription
ParseConverts the string representation of a time interval to its TimeSpan equivalent.
TryParseConverts the specified string representation of a time interval to its TimeSpan equivalent and returns a value that indicates whether the conversion succeeded.

Extract methods

MethodDescription
DaysGets the days component of the time interval that is represented by the current TimeSpan structure.
FromDaysReturns a TimeSpan that represents a specified number of days, where the specification is accurate to the nearest millisecond.
FromHoursReturns a TimeSpan that represents a specified number of hours, where the specification is accurate to the nearest millisecond.
FromMillisecondsReturns a TimeSpan that represents a specified number of milliseconds.
FromMinutesReturns a TimeSpan that represents a specified number of minutes, where the specification is accurate to the nearest millisecond.
FromSecondsReturns a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.
FromTicksReturns a TimeSpan that represents a specified time, where the specification is in units of ticks.
HoursGets the hours component of the time interval that is represented by the current TimeSpan structure.
MillisecondsGets the milliseconds component of the time interval that is represented by the current TimeSpan structure.
MinutesGets the minutes component of the time interval that is represented by the current TimeSpan structure.
SecondsGets the seconds component of the time interval that is represented by the current TimeSpan structure.
TicksGets the number of ticks that represent the value of the current TimeSpan structure.
TotalDaysGets the value of the current TimeSpan structure expressed in whole and fractional days.
TotalHoursGets the value of the current TimeSpan structure expressed in whole and fractional hours.
TotalMillisecondsGets the value of the current TimeSpan structure expressed in whole and fractional milliseconds.
TotalMinutesGets the value of the current TimeSpan structure expressed in whole and fractional minutes.
TotalSecondsGets the value of the current TimeSpan structure expressed in whole and fractional seconds.
Zero (property)Gets a zero TimeSpan value.

Format methods

MethodDescription
ToStringConverts the value of the current TimeSpan object to its equivalent string representation.

Math methods

MethodDescription
AddReturns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.
SubtractReturns a new TimeSpan object whose value is the difference between the specified TimeSpan object and this instance.

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