Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.
Function dhRoundTime(dtmTime As Date, intInterval As Integer) As Date ' Round the time value in varTime to the nearest minute ' interval in intInterval Dim intTime As Integer Dim sglTime As Single Dim intHour As Integer Dim intMinute As Integer Dim lngdate As Long ' Get the date portion of the date/time value lngdate = DateValue(dtmTime) ' Get the time portion as a number like 11.5 for 11:30. sglTime = TimeValue(dtmTime) * 24 ' Get the hour and store it away. Int truncates, ' CInt rounds, so use Int. intHour = Int(sglTime) ' Get the number of minutes, and then round to the nearest ' occurrence of the interval specified. intMinute = CInt((sglTime - intHour) * 60) intMinute = CInt(intMinute / intInterval) * intInterval ' Build back up the original date/time value, ' rounded to the nearest interval. dhRoundTime = CDate(lngdate + ((intHour + intMinute / 60) / 24)) End Function
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
25 Experts available now in Live!