shieldsco
asked on
Access Over Flow Error 6 on Time Difference
I'm getting an over flow error 6 on the line below:
intSeconds = DateDiff("s", dtmSart, dtmEnd)
intSeconds = DateDiff("s", dtmSart, dtmEnd)
dtmStart As Date, _
dtmEnd As Date _
) As String
Dim intHours As Integer
Dim intMinutes As Integer
I'm getting a stack over flow error (6) on the line below:
intSeconds = DateDiff("s", dtmSart, dtmEnd)
Dim intSeconds As Integer
Code:
intSeconds = DateDiff("s", dtmSart, dtmEnd)
intHours = intSeconds \ 3600
intMinutes = intSeconds \ 60 Mod 60
intSeconds = intSeconds Mod 60
HoursMinutes = CStr(intHours) & " Hours and " & CStr(intMinutes) & " minutes and " & CStr(intSeconds) & " seconds."
It would help if you would post your unedited code since right now it looks like neither dtmSart nor dtmEnd has been assigned a value.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I change to long the result is the call end time in military time:
Call Start Time Call End Time Call Duration
4:15:04 PM 5:16:14 PM 17 Hours and 16 minutes and 14 seconds.
Call Start Time Call End Time Call Duration
4:15:04 PM 5:16:14 PM 17 Hours and 16 minutes and 14 seconds.
As already posted: Integer can only store values from -32767 to 32767. Thus are small numbers. Use always Long as long as your requirements don't restrict your data type.
ASKER
As indicated above I changed to long see result above
dtmStart As Date, _
dtmEnd As Date _
) As String
Dim intHours As Integer
Dim intMinutes As Integer
Dim intSeconds As Long
intSeconds = DateDiff("s", dtmSart, dtmEnd)
intHours = intSeconds \ 3600
intMinutes = intSeconds \ 60 Mod 60
intSeconds = intSeconds Mod 60
HoursMinutes = CStr(intHours) & " Hours and " & CStr(intMinutes) & " minutes and " & CStr(intSeconds) & " seconds."
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured it out... Thanks used Clng
I’m glad I was able to help.
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange Most Valuable Expert (MVE) 2015, 2017
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
ASKER
Thanks Martin