Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2007, 11:11 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default different between two time

Hi... i need an idea on how to do this...
let say i have to time....

8:55:35 and 10:30:35

what is the algorithm to calculate between this to time. I need to know the number of time in same format(hh:mm:ss)...

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
__________________
surendran
(Anything is Possible)
http://www.suren.info
http://ssuren.spaces.msn.com
 
Old April 19th, 2007, 07:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

datediff will tell you the diference between 2 dates, but only in 1 format (for example only the diference in seconds...)

but after that you can compute the everything with this algorithm:
result /3600 = hours (always use integer number)
result - (hours*3600) = seconds left
newresult / 60 = minutes
newresult - (minutes*60) = seconds left


HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old April 19th, 2007, 10:03 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I don't know if the folowing will help you in your particular case, but it might.

I am taking two times as strings, converting them to dates, subtracting one from the other, and converting the result to a date. (Date type is the general type for all time-formatted items.)
The stuff I am showing is out of VB6’s Immediate Window (coloring for clarity, note the AM/PM value of the result):
Code:
?CDate( CDate("10:45:12 AM")  -  CDate("8:12:12 AM") )
2:33:00 [u]A</u>M 

?CDate( CDate("10:45:12 PM")  -  CDate("8:12:12 AM") )
2:33:00 [u]P</u>M
 
Old April 19th, 2007, 10:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

uh.. nice solution!

use brians solution surendran...

just add 12 hours when you get PM...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
synchronizing pocket pc time with desktop time bobbyrayudu83 C# 1 April 2nd, 2011 04:28 AM
Time Shift time in minus time out lechalas Beginning VB 6 1 August 11th, 2008 01:56 PM
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
How to display the time(running time) in Excel swaroop Excel VBA 1 March 29th, 2007 01:56 AM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.