sc_time_diff({datetime_01}, "Date_01 Format", {datetime_02}, "Date_02 Format")
sc_time_diff({datetime_01}, "Date_01 Format", {datetime_02}, "Date_02 Format");

This macro calculates the difference between hour, minutes and seconds for two datetime/time values.

The result will be returned in an array, with the dimensions [0], [1] and [2] containing hours, minutes and seconds, respectively.
ParĂ¢meter
Description
datetime_01
Value or variable for datetime_01
Date_01 Format
Value or variable to specify the format of datetime_01
datetime_02
Value or variable for datetime_02
Date_02 Format
Value or variable to specify the format of datetime_02
Ex. 1: General Format
{differences}  = sc_time_diff({datetime_01}, "Date_01 Format", {datetime_02}, "Date_02 Format");

{diff_hours}    = {differences[0]};
{diff_minutes}  = {differences[1]};
{diff_seconds}  = {differences[2]};


Ex. 2: Returning positive values
{differences} = sc_time_diff("2012-07-25 05:33:45", "yyyy-mm-dd hh:ii:ss", "2012-07-21 15:22:57", "yyyy-mm-dd hh:ii:ss");

{differences[0]} would be equal to 86 (hours)
{differences[1]} would be equal to 10 (minutes)
{differences[2]} would be equal to 48 (seconds)


Ex. 3: Returning negative values
{differences} = sc_time_diff("2012-07-21 15:22:57", "yyyy-mm-dd hh:ii:ss", "2012-07-25 05:33:45", "yyyy-mm-dd hh:ii:ss");

{differences[0]} would be equal to -86 (hours)
{differences[1]} would be equal to -10 (minutes)
{differences[2]} would be equal to -48 (seconds)


Ex. 4: Considering only the hours format - Positive return
{differences} = sc_time_diff("18:14:55", "hh:ii:ss", "10:55:22", "hh:ii:ss");

{differences[0]} would be equal to 7  (hours)
{differences[1]} would be equal to 19 (minutes)
{differences[2]} would be equal to 33 (seconds).


Ex. 5: Considering only the hours format - Negative return
{differences} = sc_time_diff ("10:55:22", "hh:ii:ss", "18:14:55", "hh:ii:ss");

{differences[0]} would be equal to -7  (hours)
{differences[1]} would be equal to -19 (minutes)
{differences[2]} would be equal to -33 (seconds).