Home  |  Delphi .net Home  |  System.DateTime  |  AddDays Method
  
AddDays  
Method  
Adds a number of days to the date/time
DateTime Structure
System NameSpace
CF1.  Function AddDays ( Days : Double ) : DateTime;
CF : Methods with this mark are Compact Framework Compatible
Description
Adds a number of Days to the current object datetime, returning the result.
 
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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  time : DateTime;

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

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

  time := time.AddDays(35.5);

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

  Console.ReadLine;
end.

   Time at the start    = 20 June 2004 08:30:00
   With 35.5 days added = 26 July 2004 20:30:00
Illustrating the DayOfWeek operator
program Project1;
{$APPTYPE CONSOLE}

var
  day, nextDay : DateTime;

begin
  day     := Datetime.Create(2004, 6, 20);  // June 20 2004
  nextDay := day.AddDays(1);                // June 21 2004

  Console.WriteLine('day     is a {0}', day.DayOfWeek);
  Console.WriteLine('nextDay is a {0}', nextDay.DayOfWeek);

  Console.ReadLine;
end.
   day     is a Sunday
   nextDay is a Monday
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author