Solved

How to get the day of year?

Posted on 2000-04-27
4
542 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
Comment Utility
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
Comment Utility
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
Comment Utility
kretzschmar's function is just I need
0
 

Author Comment

by:kelvinyu
Comment Utility
I just need this function, Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

12 Experts available now in Live!

Get 1:1 Help Now