# Duration data type
> Version: _Available or changed with runtime version 1.0._
Represents the difference between two DateTimes. This value can be negative. It is stored as a 64-bit integer. The integer value is the number of milliseconds during the duration.
## Instance methods
The following methods are available on instances of the Duration data type.
Method name|Description
ToText([Boolean])<duration-totext-method>|Converts the value to a text. Equivalent to calling Format(value, 0, 0).
The following are examples of durations:
DateTime-DateTime=Duration
DateTime-Duration=DateTime
DateTime+Duration=DateTime
The value of the Duration data type can also be explicitly defined in milliseconds.
## Example 1
This example shows how to calculate the difference between two DateTimes. This example is run on a computer with the Current Format in the Regional and Language Options set to English (United States).
```al
var
    DateTime1: DateTime;
    DateTime2: DateTime;
    Duration: Duration;
begin
    DateTime1 := CreateDateTime(20090101D, 080000T); // January 1, 2009 at 08:00:00 AM
    DateTime2 := CreateDateTime(20090505D, 133001T); // May 5, 2009 at 1:30:01 PM
    Duration := DateTime2 - DateTime1;
    Message(Format(Duration));
end;
```
The message window displays the following:
124 days 4 hours 30 minutes 1 second
## Example 2
The following example shows how to specify the duration of a timeout in milliseconds.
```al
procedure GetDefaultTimeout(): Duration
var
     Timeout: Duration;
begin
    Timeout := 1000 * 60 * 60; // One hour
    exit(Timeout);
end
```
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/duration/duration-data-type, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/duration/duration-data-type/
