DateTime.Difference

Syntax

Difference(StartDate: DateTime; EndDate: DateTime): TimeSpan;

Parameters

StartDate. Start date.

EndDate. End date.

Description

The Difference method calculates difference between start and end date.

Example

Sub Userproc;
Var
    d, d1: DateTime;
    t: TimeSpan;
Begin
    // Specify start date
    d := DateTime.Parse("01.01.2022 14:20:15");
    // Specify end date
    d1 := DateTime.Parse("01.01.2023 15:25:20");
    // Determine difference
    t := DateTime.Difference(d, d1);
    // Display result
    Debug.WriteLine(t.ToString);
End Sub UserProc;

After executing the example the console window displays the difference between the specified dates: 365 days, 1 hour 5 minutes and 5 seconds.

See also:

DateTime