Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date > May 15 of Dates year and < May 16 of next year 2

Status
Not open for further replies.

punky

Programmer
Mar 21, 2001
29
US
I need help checking a date field with this criteria:
The date must be greater than May 15 of the dates current year, and less than May 16 of the NEXT year. Checking dates between years throws me.
 
Code:
Function IsDateGood(dteToCheck as date) as boolean
    Dim dteLow as date
    Dim dteHigh as date
    dteLow = DateSerial(datePart("yyyy",Now),5,15) 'This yyyy
    dteHigh = DateAdd("y",1,dteLow) ' Plus 1 year
    Select Case dteToCheck
    Case Is <= dteLow       ' May 15 and below this year
    Case Is > dteHigh       ' May 16 and above next year 
    Case else
        IsDateGood = True   ' good date
    End select
End Function
 
If the &quot;dates current year&quot; means from the date to check instead of &quot;today's yyyy&quot; then use
dteLow = DateSerial(datePart(&quot;yyyy&quot;,dteToCheck),5,15)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top