Home  |  Delphi .net Home  |  System.DateTime  |  Add Method
  
Add  
Method  
Adds a time-span to the date and time
DateTime Structure
System NameSpace
CF1.  Function Add ( Span : TimeSpan ) : DateTime;
CF : Methods with this mark are Compact Framework Compatible
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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
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.

   Time at the start     = 01/01/2004 00:00:00
   With 36.5 hours added = 02/01/2004 12:30:00
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author