Calculation Number of Days Between Two Dates

Calculation Number of Days Between Two Dates


Delphi Language

Topic:

Delphi Language

  1. charlene44 wrote: 18/08/2006 at 15h08

Default calculation of number of days between two dates


  1. good morning,
  2. I have a small problem: I have dates stored in my database in date format, and with two dates I would like to find the number of days between them, so get an integer, how can I calculate that? thank you in advance.
  3. Ben_Le_Cool wrote: 18/08/2006 at 3:13pm

Default


  1. Hi,
  2. You can use the DaysBetween feature. That gives you the number of whole days between two TDateTimes.
  3. function DaysBetween(const ANow, AThen: TDateTime): Integer;
  4. e-ric wrote: 18/08/2006 at 15:22 pm

Default


  1. The previous answer is valid if you manipulate the dates in the Delphi code as TDateTime from Delphi 6 onwards otherwise
  2. 1

    2

    3

    4

    5
  3. charlene44 wrote: 19/08/2006 at 02:11am

Default


  1. thank you very much, I’ll try that!
  2. edam wrote: 19/08/2006 at 02:24am

Default

  1. Quote
    Sent by e-ric

  2. 1

    2

    3

    4

    5
  3. charlene44 wrote: 19/08/2006 at 02:36am

Default


  1. ba it works anyway, thank you very much, it gives this, I made an example very quickly to test, it’s not at all optimized but it’s okay, it gives : this
  2. edam wrote: 19/08/2006 at 02:49am

Default


  1. on the contrary this code given by eric that I prefer, and even sometimes I change all the dates and hours in integrate to facilitate the calculation
  2. mafuku wrote: 21/08/2012 at 3:06pm

Default Difference between two dates


  1. The example is made with two TDatetimePicker components that send their values to the variables p1 and p2. Just an addition to what already exists.
  2. 1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

You May Also Like