...Get the number of the day in the year?

Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Category: Math

function GetDays(ADate: TDate): Extended;
var
  
FirstOfYear: TDateTime;
begin
  
FirstOfYear := EncodeDate(StrToInt(FormatDateTime('yyyy', now)) - 1, 12, 31);
  Result      := ADate - FirstOfYear;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
label1.Caption := 'Today is the ' + FloatToStr(GetDays(Date)) + '. day of the year';
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base