INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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

*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.

computing difference between 2 times

 Forum Search FAQs Links MVPs

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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

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

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!