By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
-----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

P: n/a
Thnks MGFoster. Works well.

Jan 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.