Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Datediff

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary Fran - 13 Jul 2007 18:30 GMT
I am trying to use this function to round the difference between 2 times to
the nearest quarter hour, but if the criteria below is used for rounding,
what adjustment do I need to make to the function? (thanks)

Function:
Round((DateDiff("n", Me![Start], Me![End]) - 1) / 60 / 0.25, 0) * 0.25

Actual minutes difference table
:54 - :08 => .00
:09 - :23 => .25
:24 - :38 => .50
:39 - :53 => .75
Marshall Barton - 13 Jul 2007 21:50 GMT
>I am trying to use this function to round the difference between 2 times to
>the nearest quarter hour, but if the criteria below is used for rounding,
[quoted text clipped - 8 lines]
>:24 - :38 => .50
>:39 - :53 => .75

To round to quarter hours, you can use:
    Round(DateDiff("n", #1:37#, #1:59#) / 15) * 15

I'm not at all sure I understand what your "difference
table" is for, but if that's supposed to be the definition
of how to "round", then I think you need to create your own
function:

Public Function MyRound(dtStart, dtEnd)
Dim mins As Long, x As Long

   mins = DateDiff("n", dtStart, dtEnd)
   Select Case mins Mod 60
   Case 9 To 23
       x = 15
   Case 24 To 38
       x = 30
   Case 39 To 53
       x = 45
   Case Else
       x = 0
   End Select
   
   MyRound = mins \ 60 + x
End Function

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.