| Description |
|
The Span object holds an amount of time (ranging from milliseconds up to hours). This amount is added onto the current object datetime value and the result returned.
|
| | Notes | Like a lot of datetime methods, the datetime object itself is not affected - the modified datetime is returned for assignment.
|
|
| Microsoft MSDN Links |
System
System.DateTime
|
|
|
| A simple example |
program Project1;
{$APPTYPE CONSOLE}
var
time : DateTime;
span : TimeSpan;
begin
time := Datetime.Create(2004, 1, 1, 0, 0, 0); // Start of Jan 1st 2004
span := TimeSpan.Create(36, 30, 0); // 36.5 hour time span
Console.WriteLine('Time at the start = {0}', time);
time := time.Add(span);
Console.WriteLine('With 36.5 hours added = {0}', time);
Console.ReadLine;
end.
| | Show full unit code | Time at the start = 01/01/2004 00:00:00
With 36.5 hours added = 02/01/2004 12:30:00
|
| |
|
|
|