karl Posted December 20, 2001 Share Posted December 20, 2001 I just know that Chopper will have the answer to this one! I have a database where I record a total amount of time spent based on a calculation of "end time minus start time". Times are entered based on a 12 hour clock with AM and PM notations. My problem is when one lists say 8:00 PM to 12:00 AM the calc returns a negative number. I know it's doing this because it assumes the times are both from the same day. How can I account for times spilling over to the next day and keep my calculations correct? Karl Quote Link to comment Share on other sites More sharing options...
David Head Posted December 20, 2001 Share Posted December 20, 2001 You can try this: endTime - startTime + If(endTime Quote Link to comment Share on other sites More sharing options...
Robert Schaub Posted December 21, 2001 Share Posted December 21, 2001 Or you can add a calc field called Elasped Time = ((End Date - Start Date) * 86400) + End Time - Start Time You will have to set your times and dates with a Start Time script and a Stop Time script Quote Link to comment Share on other sites More sharing options...
Paul Brugman Posted December 22, 2001 Share Posted December 22, 2001 Loads of solutions, This is mine: If(begintime > endtime;(endtime-begintime) + 86400; endtime - begintime) Quote Link to comment Share on other sites More sharing options...
Paul Brugman Posted December 22, 2001 Share Posted December 22, 2001 Loads of solutions, This is mine: If(begintime > endtime;(endtime-begintime) + 86400; endtime - begintime) Quote Link to comment Share on other sites More sharing options...
David Head Posted December 23, 2001 Share Posted December 23, 2001 Paul, That's the same logic as mine except that I have abstracted the repetition of the "endTime - startTime" part of the calculation: Yours = If( test, A + 86400, A ) Mine = A + If( test, 86400, 0 ) where A = endTime - startTime It would be a very minor speed improvement but the logic is worth noting for larger nested calculations. Quote Link to comment Share on other sites More sharing options...
karl Posted December 26, 2001 Author Share Posted December 26, 2001 Everyone, Thank you for the help. I tested your suggestions and find David's works the smoothest and fastest. Thank you all again Karl Quote Link to comment Share on other sites More sharing options...
fayzal Posted January 20, 2002 Share Posted January 20, 2002 err guys i cant figure out why you need the 86400 for what is it stand for ? Quote Link to comment Share on other sites More sharing options...
Robert Schaub Posted January 20, 2002 Share Posted January 20, 2002 86400 represents the number of seconds in a day. this part is needed in order to calc time that carries over into the next day. Quote Link to comment 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.