Delphi Basics Home  |  Delphi Basics .NET Home  |  System.DateTime  |  AddTicks Method
AddTicks  
Method  
Adds a number of ticks to the date/time
DateTime Structure
System NameSpace
CF1.  Function AddTicks ( Ticks : Int64 ) : DateTime;
CF : Methods with this mark are Compact Framework Compatible
Description
Adds a number of Ticks to the current object datetime, returning the result. A tick is 0.0000001 seconds (100 nanoseconds).
 
You can subtract by specifying a negative number, or using the Subtract method.
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
System.DateTime.AddTicks
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  time : DateTime;

begin
  time := Datetime.Create(2004, 6, 20, 08, 30, 0);  // 08:30 on June 20 2004

  Console.WriteLine('Time at the start          = {0:F}', time);

  time := time.AddTicks(750000000);  // 1 minute 15 seconds

  Console.WriteLine('With 750000000 ticks added = {0:F}', time);

  Console.ReadLine;
end.
   Time at the start          = 20 June 2004 08:30:00
   With 750000000 ticks added = 20 June 2004 08:31:15
 
© CodeGear 2006 - 2007. All rights reserved.