Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

start date from end date

Status
Not open for further replies.

MARTINRODDY

Programmer
Apr 3, 2001
30
US
how can i subtract one date from another to get the deifference in seconds.

e.g.
start date - end date

Any help appreciated

Martin
 
Convert the start date and the end date to seconds and then substract them from eachother. You could do this by making seperate field for ady month and year and then adding calculate what they are in seconds add them up, and then subtract them...

Cood luck,

BobbaFet Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
Be a nice guy 'n press that little ol' button
VVV---(this one) for me ;-)
 
Here is some code that will do that conversion.

function SecondsBetweenDates(const StartDate, StopDate : TDateTime) : cardinal;
const
SecondsPerDay = 60 * 60 * 24;
RoundFactor = 0.5;
var
DateDiff : TDateTime;
begin
DateDiff := StopDate - StartDate;
result := trunc(DateDiff * SecondsPerDay + RoundFactor);
end;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top