Solved

# How to get the day of year?

Posted on 2000-04-27
Medium Priority
552 Views
has a function which can return the day of year at Delphi 4?

Thanks
0
Question by:kelvinyu
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 3

Expert Comment

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

kretzschmar earned 200 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

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

Author Comment

ID: 2768133
I just need this function, Thanks
0

## Featured Post

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
###### Suggested Courses
Course of the Month10 days, 3 hours left to enroll