date time - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# date time

Posts: 13Member
I want to calculate the number of days between 2 spesified dates.
Thanx for the help
Peter

• Posts: 179Member
: I want to calculate the number of days between 2 spesified dates.
: Thanx for the help
: Peter
:
:

Hi,

Use DaysBetween in the unit DateUtils.

Unit

DateUtils

Category

date/time routines

function DaysBetween(const ANow, AThen: TDateTime): Integer;

Description

Call DaysBetween to obtain the difference, in days, between two TDateTime values.

DaysBetween counts only whole days that have elapsed. Thus, DaysBetween reports the difference between Dec 31, 1999 11:59 PM and Jan 1, 2000 11:58 PM as 0 because the difference is one minute short of an entire day.
• Posts: 188Member
: : I want to calculate the number of days between 2 spesified dates.
: : Thanx for the help
: : Peter
: :
: :
:
: Hi,
:
: Use DaysBetween in the unit DateUtils.
:
: Unit
:
: DateUtils
:
: Category
:
: date/time routines
:
: function DaysBetween(const ANow, AThen: TDateTime): Integer;
:
: Description
:
: Call DaysBetween to obtain the difference, in days, between two TDateTime values.
:
: DaysBetween counts only whole days that have elapsed. Thus, DaysBetween reports the difference between Dec 31, 1999 11:59 PM and Jan 1, 2000 11:58 PM as 0 because the difference is one minute short of an entire day.
:
Because a date-time in Delphi is a float value, which contains the number of days (and day fractions) after 1899 (or something), you can simply calculate with TDateTime's. In the above example the difference would be 0.9999 days (or something). You can do a roundup or truncate yourself.