2. Function to the date of the day before a given date


			
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  'Name:  de_DayBefore
  '
  'Comments:
  '   Given a starting date, this function returns the date of the day before
  '   the starting Date
  '
  'In:    dteStartDate --> The date from which to figure the day before
  '
  'Out:   The date of the day before
  '
  'Examples:
  '       1. To return the last day of June, 1998
  '
  '               de_DayBefore(#07/01/98#)
  '
  'Created: 09/02/98 by Stephen Negus
  '
  'Modifications:
  'Date           Author              Description
  '
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  Function de_DayBefore(dteStartDate As Date) As Date
  On Error GoTo de_DayBefore_Err
  Dim intYear As Integer, intMonth As Integer, intDay As Integer

  intYear = DatePart("yyyy", dteStartDate)
  intMonth = DatePart("m", dteStartDate)
  intDay = DatePart("d", dteStartDate)

  If intDay = "1" Then
      Select Case intMonth
          Case 1
              intYear = intYear - 1
              intMonth = 12
              intDay = 31
          Case 3
              intMonth = intMonth - 1
              If de_LeapYear(intYear) Then
                  intDay = 29
              Else
                  intDay = 28
              End If
          Case 2, 4, 6, 8, 9, 11
              intMonth = intMonth - 1
              intDay = 31
          Case 5, 7, 10, 12
              intMonth = intMonth - 1
              intDay = 30
          
      End Select
  Else
      intDay = intDay - 1
  End If

  de_DayBefore = intMonth & "/" & intDay & "/" & intYear
  
  de_DayBefore_Exit:
      Exit Function
 
  de_DayBefore_Err:
      Dim strMsg As String
      strMsg = "Error " & Err.Number & " has occurred."
      strMsg = strMsg & " The Description is: " & Err.Description
      MsgBox strMsg
      Resume de_DayBefore_Exit
  End Function

			

Copyright © 1999-2000, Doulos Enterprises
All Rights Reserved
Terms of Use