Thread: Rounding Time
View Single Post
  #10  
Old May 19th, 2010, 06:25 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Rounding Time

Internally, a Date variable is an 8 byte floating point number. In other
words, it's a Double.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"Bre-x" wrote in message
...
Hi

You are declaring the dTime as a Date Variable
the first variable that the RoundTo Function is expecting is a Double

I am missing something here?





Literal example
CDate(Roundto(#8:14:59#,#00:15:00#))

Variable example
Dim dTime as Date
dTime = #8:14:59#
CDate(Roundto(dTime,#00:15:00#))


Public Function RoundTo(dblVal As Double _
, dblTo As Double _
, Optional intUpDown As Integer = -1) As Double

' rounds up by default.
' to round down pass 1 into function as
' optional intUpDown argument.
RoundTo = intUpDown * (Int(dblVal / (intUpDown * dblTo))) * dblTo