DelphiBasics
PDateTime
Type
Pointer to a TDateTime value System unit
  type PDateTime = ^TDateTime;
Description
The PDateTime type is a pointer to a TDateTime value.
 
Pointer arithmetic, such as Inc, Dec can be used on it, for example to navigate a block of TDateTime values, as in the example.
Related commands
Dec Decrement an ordinal variable
Inc Increment an ordinal variable
TDateTime Data type holding a date and time value
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Store 3 TDateTime values in memory and navigate through them
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  DateUtils, SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  dateTimePtr : PDateTime;
  a : TDateTime;

begin
  // Allocate storage for three date time variables
  GetMem(dateTimePtr, 3 * SizeOf(Extended));

  // Fill out these date time variables
  dateTimePtr^ := Yesterday;
  Inc(dateTimePtr);
  dateTimePtr^ := Date;
  Inc(dateTimePtr);
  dateTimePtr^ := Tomorrow;

  // Now display these values
  Dec(dateTimePtr, 2);
  ShowMessage('Yesterday = '+DateToStr(dateTimePtr^));
  Inc(dateTimePtr);
  ShowMessage('Today     = '+DateToStr(dateTimePtr^));
  Inc(dateTimePtr);
  ShowMessage('Tomorrow  = '+DateToStr(dateTimePtr^));
end;
 
end.
Hide full unit code
   Typical program output:
  
   Yesterday = 10/04/2003
   Today     = 11/04/2003
   Tomorrow  = 12/04/2003
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page