Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
date time Posted by pietervr on 25 Feb 2004 at 4:39 AM
I want to calculate the number of days between 2 spesified dates.
Thanx for the help
Peter

Report
Re: date time Posted by Tief on 25 Feb 2004 at 6:00 AM
: 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.
Report
Re: date time Posted by Masterijn on 25 Feb 2004 at 2:27 PM
: : 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.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.