Re: finding the day of the year




"anthony" <mrmclarge@xxxxxxxxxxx> wrote in message
news:UVNFe.3942$PL5.367940@xxxxxxxxxxxxxxxxxx
> Doews anyone know how I can find the day of the year. If I select a date
> with datepicker how can I then set about finding what number day of the
> year it is
>
> eg: 1/1/2005 would be day 1
> eg: 12/31/whatever year would be day 365 or 366 depending if it is a
> leap year.

Subtract the date of the first day of the year from the date and add one.

function DayOfYear (aDate : tDateTime) : integer;

var yr, mth, day : word;

begin
DecodeDate (aDate, yr, mth, day);
result := (aDate - EncodeDate (yr, 1, 1)) + 1;
end;


.



Relevant Pages

  • Re: finding the day of the year
    ... >Doews anyone know how I can find the day of the year. ... >with datepicker how can I then set about finding what number day of the ... See the DayOfTheYear function ... Prev by Date: ...
    (alt.comp.lang.borland-delphi)
  • Re: finding the day of the year
    ... >Doews anyone know how I can find the day of the year. ... >with datepicker how can I then set about finding what number day of the ... >leap year. ... Prev by Date: ...
    (alt.comp.lang.borland-delphi)
  • finding the day of the year
    ... Doews anyone know how I can find the day of the year. ... If I select a date with datepicker how can I then set about finding what number day of the year it is ... I have had this code somewhere, but with disk crashes etc I no longer have it ... Anthony ...
    (alt.comp.lang.borland-delphi)