Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any rounding format for time?

Status
Not open for further replies.

fuyu

Programmer
Jan 2, 2001
3
0
0
SG
I have to round the time to the nearest 30mins. Is there a function for it?
 
Not that I know of. It wouldn't be too hard to build your own (or roll your own if you are a child of the '70s)

Function RoundTime(myTime as Date) as Date
dim intMin as integer

intMin = Minute(myTime)

if intMin <15 then
RoundTime=dateAdd(&quot;n&quot;,-intMin,mytime)
elseif intMin>=15 or intMin<30 then
RoundTime=dateAdd(&quot;n&quot;,30-intMin,mytime)
elseif intMin>30 or intMin<=45 then
RoundTime=dateAdd(&quot;n&quot;,-(intMin-30),mytime)
elseif intMin > 45 then
RoundTime=dateAdd(&quot;n&quot;,60-intMin,mytime)
end if

end function

That's OTOMH, so it may have errors, but it should get you started. Kathryn


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top