Microsoft KB Archive/210498

= ACC2000: Function to Get Date of Monday Prior to Current Day =

Article ID: 210498

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210498



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
This article describes a function that you can use to find the date of the Monday prior to the current day.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.



MORE INFORMATION
The following function determines Monday's date according to the following criteria:
 * 1) If the current date is Tuesday through Sunday, it yields the date of the prior Monday.
 * 2) If the current day is Monday, it returns the current date.
 * 3) If the date is Null or is not a valid date, it returns Null.

To create this function, follow these steps:   Create a module and type the following line in the Declarations section if it is not already there: Option Explicit   Type the following procedure: Function GetMonDate(CurrentDate) If VarType(CurrentDate) <> 7 Then GetMonDate = Null Else Select Case Weekday(CurrentDate) Case 1      ' Sunday GetMonDate = CurrentDate - 6 Case 2      ' Monday GetMonDate = CurrentDate Case 3 To 7 ' Tuesday..Saturday GetMonDate = CurrentDate - Weekday(CurrentDate) + 2 End Select End If End Function 

To test the function, type the following line in the Immediate window, and then press ENTER: ? GetMonDate(#4/30/93#) Note that the following result will be displayed in the Immediate window:   #4/26/93#

Keywords: kbhowto kbprogramming KB210498

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.