473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Showing the difference between two times in Hours, Minutes and Seconds

Brendan Reynolds posted the following function a while back ago:

Public Function HoursMinutes( _
dtmStart As Date, _
dtmEnd As Date _
) As String
Dim intHours As Integer
Dim intMinutes As Integer
intMinutes = DateDiff("n", dtmStart, dtmEnd)
intHours = intMinutes \ 60
intMinutes = intMinutes Mod 60
HoursMinutes = CStr(intHours) & " Hours and " & CStr(intMinutes) &
"
minutes."

I was wondering if anyone could modify this so it showed seconds as
well.

Thanks

Jan 19 '06 #1
2 23185
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dim intSeconds As Integer

intSeconds = DateDiff("s", dtmSart, dtmEnd)
intHours = intSeconds \ 3600
intMinutes = intSeconds \ 60 mod 60
intSeconds = intSeconds mod 60

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9AD64echKqOuFEgEQKoQQCgz4oh3h57IQhFYUkMuApBqe iFYr4AoJIP
M/17zicVhHNAvRBudAsnbmp7
=w9sj
-----END PGP SIGNATURE-----
BerkshireGuy wrote:
Brendan Reynolds posted the following function a while back ago:

Public Function HoursMinutes( _
dtmStart As Date, _
dtmEnd As Date _
) As String
Dim intHours As Integer
Dim intMinutes As Integer
intMinutes = DateDiff("n", dtmStart, dtmEnd)
intHours = intMinutes \ 60
intMinutes = intMinutes Mod 60
HoursMinutes = CStr(intHours) & " Hours and " & CStr(intMinutes) &
"
minutes."

I was wondering if anyone could modify this so it showed seconds as
well.

Thanks

Jan 19 '06 #2
Thnks MGFoster. Works well.

Jan 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the...
1
by: mark | last post by:
I'm stuck: In a query I am trying to compare two fields with a date/time data type and a LongTime format to get the difference in hours (minutes and seconds if possible). After that I need to...
2
by: J M | last post by:
I rebooted a network device just few minutes ago and getting device-up-time value 3191. How do I convert a time elapsed in days hours minutes and seconds for above value? Example: This device...
2
by: Randall Parker | last post by:
I know I could just get the year,month,day, etc of of each DateTime vars and calc the hours difference between them. I've done this before in other languages with a formula for handling leap years....
5
by: Lad | last post by:
Hello, what is the best /easest way how to get number of hours and minutes from a timedelta object? Let's say we have aa=datetime.datetime(2006, 7, 29, 16, 13, 56, 609000)...
3
by: Drew | last post by:
I've got three columns i'm working on: Time Start (Date and Time), Time End (Date and Time), Total Task Time (Short Time) I've got Total Task Time working correctly. Here is my query: SELECT...
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
3
by: RN1 | last post by:
A Form has 2 TextBoxes where in users enter date & time. Example (in mm/dd/yyyy format): 09/20/2008 17:54 (1st TextBox) 09/29/2008 6:13 (2nd TextBox) How do I find out how much time (in...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.