SmartPascal
DayOfTheYear
Function
Gives the day of the year for a TDateTime value (ISO 8601) DateUtils unit
 function DayOfTheYear ( const Date : TDateTime ) : Word;
Description
The DayOfTheYear function returns an index number for the day of the year.
 
Depending on the year, the value is in the range 1..366
Related commands
DayOfTheMonth Gives day of month index for a TDateTime value (ISO 8601)
DayOfTheWeek Gives day of week index for a TDateTime value (ISO 8601)
DayOfWeek Gives day of week index for a TDateTime value
MonthOfTheYear Gives the month of the year for a TDateTime value
 
Example code : Show the day of the year for a TDateTime variable
// 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
  DateUtils,   // Unit containing the DayOfTheYear command
  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
  myDate : TDateTime;

begin
  myDate := EncodeDate(2002, 10, 29);
  ShowMessage('20/10/2002 day of year  = '+
              IntToStr(DayOfTheYear(myDate)));
end;
 
end.
Hide full unit code
   20/10/2002 day of the year = 302