Skip to content

Calendar.Subtract

Overview

Number Calendar.Subtract ( start, end )
Returns the difference between the specified start and end date time values in hours.

Arguments

DateTimeOffset start Specifies the start date time value.

DateTimeOffset end Specifies the end date time value.

Remarks

Please make sure that you are using the right calendar object, since adding time is related with your calendar of choice. You can have more info on Calendar definitions by checking the $Calendar object.

Examples

var currentDate = $Calendar.Today;

$Xml.SetValue('Result1', $Calendar.StandardCalendar.Subtract(currentDate, $Calendar.AddDays(currentDate, -1)));

//using the defined calendar with work hours.
$Xml.SetValue('Result2', $Calendar.Subtract(currentDate, $Calendar.AddDays(currentDate, -1)));

Result is

<Result1>24</Result>
<Result2>9</Result>

See Also