Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find dateutils

Status
Not open for further replies.

yomyom

Programmer
Dec 23, 2002
119
GB
I use delphi 4 and would like to make use of daysbetween() function but I cannot find dateutils. Where is dateUtils?
can someone pls put me out of my misery? as in tell me where to find it.
Thanks in advance,
yomyom.
 
I think DateUtils showed up in Delphi 6. If I remember the other thread correctly, you wanted to do some date math. Since the TDateTime is a double, with integer representing a day, I'm pretty sure you can do what you want like this:

Trunc(Date1) - Trunc(Date2)

The code from Dateutils for daysbetween boils down to this(ANow and AThen are TDateTime parameters):


if ANow < AThen then
Result := AThen - ANow
else
Result := ANow - AThen;

result := trunc(result);

Brian
&quot;There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group.&quot; - tag line I stole
 
Hi.

I do not have Delphi four, but in Delphi 6 and 7 you can find it here:
C:\Program Files\Borland\Delphi7\Source\Rtl\Common

but I also believe you can manage with DateUtils.dcu file only:
C:\Program Files\Borland\Delphi7\Lib

Check it out with Delphi4

mihael
 
I use this code to give the day of the year (ie Feb 10th is the 41st day of the year). It may give you another idea for doing date math.:

function FindDayOfYear(dDate: TDateTime): string;
var
Year, Month, Day: Word;
dTotal, dRounded: double;
begin
DecodeDate(dDate, Year, Month, Day);
dRounded := Round(dDate);
if dRounded < dDate then
dRounded := dRounded + 1;
dTotal := dRounded - EncodeDate(Year,1,1);
Result := FloatToStr(dTotal) + ' ' + IntToStr(Year);
end;
 
Thanks for your reponses.
I settled for :=
.....
var date1,date2: TDate;
DaysBetween: double;
begin
date1 := dateTimePicker1.date;
date2 := dateTimePicker2.date;
DaysBetween := date2 - date1 + 1;
......
Taxpaid := Totb4tax * (daysbetween/365) * taxrate;

hope this will also help others....
yomyom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top