Solved

How to get the day of year?

Posted on 2000-04-27
4
544 Views
Last Modified: 2012-05-04
has a function which can return the day of year at Delphi 4?

Thanks
0
Comment
Question by:kelvinyu
  • 2
4 Comments
 
LVL 3

Expert Comment

by:shenqw
ID: 2758125
procedure TForm1.Button1Click(Sender: TObject);
var
  Year,Month,Day:Word;
begin
  DecodeDate(now,Year,Month,Day);
  ShowMessage(IntToStr(Day));
end;
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 2758198
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
 

Author Comment

by:kelvinyu
ID: 2768129
kretzschmar's function is just I need
0
 

Author Comment

by:kelvinyu
ID: 2768133
I just need this function, Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now