Steve_God
07-01-2003, 04:03 AM
Hi,
Is there a simple way of getting access to round the time to the nearest 5 or 10 minutes :)
Thanks :)
Is there a simple way of getting access to round the time to the nearest 5 or 10 minutes :)
Thanks :)
|
View Full Version : Rounding to the nearest X Minutes Steve_God 07-01-2003, 04:03 AM Hi, Is there a simple way of getting access to round the time to the nearest 5 or 10 minutes :) Thanks :) Travis 07-01-2003, 07:25 AM Here is a function that will convert the time to the nearest 5 or 10. Public Function RoundTime(ByVal dTime As Date) As Date Dim min As String Dim rnd As Integer Dim add As Double min = DatePart("n", dTime) rnd = Right(min, 1) add = 0 Select Case rnd Case 0, 5: add = 0 Case 1, 6: add = -1 Case 2, 7: add = -2 Case 3, 8: add = 2 Case 4, 9: add = 1 End Select RoundTime = DateAdd("n", add, dTime) End Function |