date time - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

date time

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

Comments

  • TiefTief 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.
  • MasterijnMasterijn 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.


Sign In or Register to comment.