doubledee Posted March 18, 2012 Share Posted March 18, 2012 If I want to subtract a Date/Time in Record #1 from Record #2, how would I do that? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/ Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2012 Share Posted March 18, 2012 TIMEDIFF() Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/#findComment-1328649 Share on other sites More sharing options...
doubledee Posted March 18, 2012 Author Share Posted March 18, 2012 TIMEDIFF() That isn't what I asked about... I asked how to do math on RECORDS (as opposed to VALUES). Even more so, if I had 100 records, and I wanted to subtract adjacent Records, then how would I do that? Record 1 - Record 2 Record 2 - Record 3 Record 3 - Record 4 : : : Debbie Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/#findComment-1328652 Share on other sites More sharing options...
fenway Posted March 18, 2012 Share Posted March 18, 2012 SQL isn't designed to operate on pairs of rows -- you'll have to fake it with a user variable, or use a self-join, assuming you "know" how to find record N+1. Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/#findComment-1328787 Share on other sites More sharing options...
doubledee Posted March 18, 2012 Author Share Posted March 18, 2012 SQL isn't designed to operate on pairs of rows -- you'll have to fake it with a user variable, or use a self-join, assuming you "know" how to find record N+1. So INSERTING a new record everytime a User hopes from Page to Page and then trying to subtract the TimeStamps of each record to determine the "Time on page" wouldn't be a good strategy, huh? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/#findComment-1328827 Share on other sites More sharing options...
fenway Posted March 25, 2012 Share Posted March 25, 2012 Oh, it can be done -- it just might be easier to calculate in PHP if this is a "one-time" thing, and then update the corresponding rows. Quote Link to comment https://forums.phpfreaks.com/topic/259183-comparing-records/#findComment-1330902 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.