🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7584

Re: TDateTime difference

#7584
From: Keith
Date: Fri, 21 Jan 2005 05:04
21 lines
1236 bytes

Danid wrote:

> How can I calculate the difference between two dates and have the results in hours?
> Example:
>
> d1 = 12-04-2004 21:10:00
> d2 = 12-04-2004 23:40:00
>
> difference is 2.5
> Thanks,

TDateTime d1, d2;

d1=Now();
d2=d1+1;          // d2 is the current time plus one day

double dif=(d2-d1);
dif *= 24.0;           // dif is 24
Edit1->Text=FloatToStr(dif);
Technical Details
Message-ID: <41F08D69.AA1DFAC5@sbcglobal.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41f03f28$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a03d5ca673360fd6
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <41F08D69.AA1DFAC5@sbcglobal.net>
Date: Thu, 20 Jan 2005 23:04:41 -0600
From: Keith <kdopson@sbcglobal.net>
X-Mailer: Mozilla 4.79 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: TDateTime difference
References: <41f03f28$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.71.227.84
X-Trace: newsgroups.borland.com 1106283792 65.71.227.84 (20 Jan 2005 21:03:12 -0800)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail