How to get the day of year?

has a function which can return the day of year at Delphi 4?

Thanks
kelvinyuAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kretzschmarConnect With a Mentor Commented:
hi,

my guess, about what is wanted

function DayOfYear(DT : TDateTime) : Integer;
var dt1,dt2 : TDateTime;
    m,d,y    : Word;
begin
  dt1 := Trunc(DT);
  decodeDate(dt1,y,m,d);
  dt2 := encodeDate(y,1,1);
  Result := Trunc(dt1-dt2);  //maybe +1
end;

//sample to call
procedure TForm1.Button1Click(Sender: TObject);
begin
  edit1.text := inttostr(DayOfYear(DateTimePicker1.Date));
end;

meikl
0
 
shenqwCommented:
procedure TForm1.Button1Click(Sender: TObject);
var
  Year,Month,Day:Word;
begin
  DecodeDate(now,Year,Month,Day);
  ShowMessage(IntToStr(Day));
end;
0
 
kelvinyuAuthor Commented:
kretzschmar's function is just I need
0
 
kelvinyuAuthor Commented:
I just need this function, Thanks
0
All Courses

From novice to tech pro — start learning today.