UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> Sandbox:TesttemplateFL    


Tests the number of elapsed dates since a starting point to determine if the specified duration in days has elapsed

' TesttemplateFL
' http://www.utteraccess.com/wiki/Sandbox:TesttemplateFL
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2010-09-11                    
Public Function fGracePeriodValid(rdtStartDate As Date, _
                               riDuration As Integer) As Boolean
' Procedure: fGracePeriodValid
' DateTime: 09/11/2010 5:51:11 AM
' Description: tests the number of elapsed dates since a starting point
'              to determine if the specified duration in days has elapsed
'   rdtStartDate date on which the grace period started
'   riDuration number of days allowed in the grace period'
'   returns true if one or more days of the grace period have not elapsed
'           false if the grace period has elapsed
'NOTE: if grace periods will be tested might exceed 32,767 days (~89 years)
'      then a long variable should be used for the elapsed period calculation
  Const cstrProcedure = "fGracePeriodValid"
  Dim intElapsed As Integer
  Dim blnResult As Boolean
  On Error GoTo HandleError
  intElapsed = DateDiff("d", rdtStartDate, Date)

  If intElapsed <= riDuration Then
      blnResult = True
      blnResult = False
  End If

  fGracePeriodValid = blnResult
  Exit Function


  Select Case Err
  Case 6  'overflow rdtStartDate is more then 32767 days before current date
      blnResult = False
  Case Else
      MsgBox "Error " & Err & "in " & cstrProcedure
      blnResult = False
  End Select
  Resume HandleExit
End Function

Creative Commons License
TesttemplateFL by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 2,877 times.  This page was last modified 20:23, 9 November 2010 by Glenn Lloyd.   Disclaimers