INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

computing difference between 2 times

computing difference between 2 times

(OP)
Hi. how do I compute the difference between two times? In the result, I want to see the hour difference and minute difference as HH:MM, not just the hour or minute. the time1 and time2 are formatted 'YYYY-MM-DD HH:MM:mm.ss'. I only want the HH:MM part from the computed difference. Thank you.

RE: computing difference between 2 times

Try the SecondsAfter function, it gets the number of seconds one time occurs after another. Syntax :

SecondsAfter ( time1, time2 )

Then just devide by 60 for minutes and 60 again for hours... hope this helps

RE: computing difference between 2 times

Hi,

Your solution to your problem is to use the SecondsAfter() function. It returns a long value of seconds being the difference between the two time values. To conver this value to a time format, just use the String() function to format the computation:

//////////////////////////////////////////////////////////
time   lt_Time1, lt_Time2 ;
long   ll_Secs ;
string ls_Diff ;
//
ll_Secs = SecondsAfter( lt_Time1, lt_Time2 ) ;
//
ls_Diff = String(( ll_Secs / 60 ) / 60 ) + ":" + String( ll_Secs / 60 )
//////////////////////////////////////////////////////////

Hope this helps...

--
PowerObject!
-----------------------------------------
http://groups.yahoo.com/group/PowerObject
PowerBuilder/PFC Developers' Group

RE: computing difference between 2 times

(OP)
Thank you for your help. I'll try that out. Thanks again.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close