#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    TIME Calculations


    I need to calculate the amount of hours (or minutes) between 2 dates and 2 times. There are 4 objects (datetime pickers) on the form.

    For example

    01/01/2014 22:00
    02/02/2014 05:30

    This should read 450 min or 7.5 hours. I just need the integer (number) 450.

    How would on go by doing this?

    Ive tried to figure this out. First i need to see if the 2 dates is on the same day. If not the 1t date should be BEFORE the 2nd date.

    If its the same day i assume the calculation should be easy and obviously the outcome should be les than 24 hours (1440) min. BUT I HAVE NO IDEA WHERE TO START?

    Please help.

    Thanks in advanced!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    354
    Rep Power
    7
    There's a function called MinutesBetween that is already part of Delphi. You'll need to add System.DateUtils or (DateUtils if pre-XE2) to your Uses clause.

    http://docwiki.embarcadero.com/Libraries/XE3/en/System.DateUtils.MinutesBetween
    Last edited by majlumbo; February 27th, 2014 at 01:36 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    Re


    Thanks majlumbo. It worked like a charm. Thank you so much you always helped me alot with your replies. I have another Time date issue which i will create a new post for. But first let me see if i can sort it out with this procedure in the dateutils. Thanks again

IMN logo majestic logo threadwatch logo seochat tools logo