UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GracePeriodValid    


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

' GracePeriodValid
' http://www.utteraccess.com/wiki/GracePeriodValid
' 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.01  2010-11-09                    Original Code
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
GracePeriodValid 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 7,484 times.  This page was last modified 08:41, 6 April 2011 by Jack Leach. Contributions by Glenn Lloyd  Disclaimers