Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: robbie varga
  Where is robbie varga?
 beds
 United Kingdom
 robbie varga
Subject: RE: Help calculating time differences
Thread ID: 438860 Message ID: 438880 # Views: 49 # Ratings: 2
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, August 4, 2016 11:52:44 AM         
   



> Hi everyone
>
> I have a large database which stores eventlogs for our programs etc
>
> I would like to be able to calculate the difference between time values in record 2 and record 1 and so on so that
> I end up with a database containing the difference between the timevalue in the current record and the record previous to this.
>
> I dont mind if the time calculations displays the information in minutes, seconds etc, i just need to be able to get this information.
>
> Any help would be much appreciated
>
> e.g.
>
>
>
> RECORD NO TIMELOGGED TIME DIFFERENCE
>
> 1 13:00.00 -
> 2 13:02.00 60 Seconds
> 3 13:05.00 180 Seconds
> 4 13:20.00 900 Seconds
>
>
> Kind regards
>
> Robbie

Because it's for fun, another SQL solution

CREATE CURSOR cCur (TIMELOGGED T)
INSERT INTO cCur VALUES (DATETIME(2016,8,3,13,0,0))
INSERT INTO cCur VALUES (DATETIME(2016,8,3,13,2,0))
INSERT INTO cCur VALUES (DATETIME(2016,8,3,13,5,0))
INSERT INTO cCur VALUES (DATETIME(2016,8,3,13,20,0))

SELECT RecordNo, TIMELOGGED, ;
	IIF(RecordNo = 1,CAST(0 as integer), TIMELOGGED - (SELECT TIMELOGGED FROM cCurWithId c0 WHERE cCurWithId.RecordNo = c0.RecordNo + 1)) as TimeDifference ;
	FROM cCurWithId 



Respectfully
http://praisachion.blogspot.ro/

ENTIRE THREAD

Help calculating time differences Posted by robbie varga @ 8/3/2016 5:34:19 PM
RE: Help calculating time differences Posted by Rahul Moudgill @ 8/3/2016 6:44:36 PM
RE: Help calculating time differences Posted by Borislav Borissov @ 8/3/2016 6:45:31 PM
RE: Help calculating time differences Posted by Vilhelm-Ion Praisach @ 8/3/2016 6:47:36 PM
RE: Help calculating time differences Posted by Stefan Wuebbe @ 8/3/2016 6:47:42 PM
RE: Help calculating time differences Posted by Vilhelm-Ion Praisach @ 8/4/2016 11:52:44 AM
RE: Help calculating time differences Posted by Pete Sass @ 8/4/2016 6:55:47 PM