Thank you everybody for your help
And the winner is.....
John
heres what seems to work
SELECT clientinfo.FName, DateSerial(Year(Date()),Month([Dob]),Day([Dob])) AS
Birthday
FROM clientinfo
WHERE (((DateSerial(Year(Date()),Month([Dob]),Day([Dob]))) Between Date()-30
And Date()+30
Or (DateSerial(Year(Date()),Month([Dob]),Day([Dob]))) Between
DateAdd("yyyy",-1,Date()-30) And DateAdd("yyyy",-1,Date()+30)
Or (DateSerial(Year(Date()),Month([Dob]),Day([Dob]))) Between
DateAdd("yyyy",1,Date()-30) And DateAdd("yyyy",1,Date()+30)));
I added another OR to your suggeation with a +1 dateAdd and that seems to
cover the issue.. Thank you
I found a great post by Dale Fye under "Find anniversary of a date" in
queries it deffinately gets Honorable Mention but i was hoping not to add a
module. so i didnt use it
'Since you didn't indicate that you want to identify which anniversary (1,
'10, etc), another alternative is to create a function and pass it the
'values. I function I have for this purpose, which I have provided below.
'There are a couple of advantages to this function:
'
'1. you are not limited to next month, you just have to pass it any two
'dates.
'2. much easier to read and maintain
'
'To call the function in a query just add a column:
'
'IsAnniversary([Birthday], #1/1/06#, #1/31/06#)
'
'If you actually want to know which anniversary, then you can change the
'IsAnniversary function to an Anniversary function by changing the Return
'data type to variant (you probably want to return a Null if the anniversary
'does not fall between the two dates) and determining the number of years
'difference using the datediff( ) function in the sections of code where I am
'currently setting IsAnniversary to True.
Public Function IsAnniversary(SomeDate As Variant, _
StartDate As Date, _
EndDate As Date) As Boolean
Dim intDay As Integer
Dim intMonth As Integer
If IsNull(SomeDate) Then
IsAnniversary = False
Exit Function
End If
intDay = Day(SomeDate)
intMonth = Month(SomeDate)
If DateSerial(Year(StartDate), intMonth, intDay) >= StartDate _
And DateSerial(Year(StartDate), intMonth, intDay) <= EndDate Then
IsAnniversary = True
ElseIf DateSerial(Year(EndDate), intMonth, intDay) >= StartDate _
And DateSerial(Year(EndDate), intMonth, intDay) <= EndDate Then
IsAnniversary = True
Else
IsAnniversary = False
End If
End Function
John Spencer said:
Calculate the birthday using the following:
DateSerial(Year(Date()),Month([DateOfBirth]),Day ([DateOfBirth]))
Set the criteria for the Birthday column to:
Between Date() and Date() + 60 OR
Between DateAdd("yyyy",-1,Date()) and DateAdd("yyyy",-1,Date()) + 60
In SQL that would look something like:
Select PersonName,
DateSerial(Year(Date()),Month([DateOfBirth]),Day ([DateOfBirth])) as Birthday
FROM tablename
WHERE
DateSerial(Year(Date()),Month([DateOfBirth]),Day ([DateOfBirth]))
Between Date() and Date() + 60
OR
DateSerial(Year(Date()),Month([DateOfBirth]),Day ([DateOfBirth]))
Between DateAdd("yyyy",-1,Date()) and DateAdd("yyyy",-1,Date()) + 60
If you want plus or minus x days then you can change the +60 to +5 and
subtract 5 from the first date in the between clauses.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Steve
Nice touch with the date diff but criteria didnt work.
so i tried
Works great for dates but not birthdays as 1-7-1968 is further back than 5
days
any other ideas would be appreciated
Steve said:
Hi Barry,
In the query design grid in the first blank field, put the following
expression:
ShowPopup= DateDiff("d",BirthDate,Date())
Put the following expression in the criteria of this field:
<-5 OR >5
You then need code to open your popup for each client returned by this
query.
Steve
(e-mail address removed)
I have a little birthday notification popup that shows clients that have or
have had a birthday in the next 5 or last 5 days from the current date and
some other junk to concatenate the notification..
Because i used Between Day(Date())-5 And Day(Date())+5)) the criteria does
not work in the beginning or end of the month. as it would look for the
35th
day in january instead of 5th of febuary. is there a correct way to do
this.
SELECT ClientInfo.ClientID, ClientInfo.FirstName, ClientInfo.LastName,
Format([DOB],"dddd"", ""mmm"", ""d") AS bday, Month([DOB]) AS bdmonth,
Day([DOB]) AS bdday,
DateDiff("yyyy",[DOB],Date())-IIf(Format([DOB],"mmdd")>Format(Date(),"mmdd"),1,0)
AS Age, IIf(Format([DOB],"mmdd")>Format(Date(),"mmdd"),"Will Be ","Just
Turned ") AS Agetext,
[age]+IIf(Format([DOB],"mmdd")>Format(Date(),"mmdd"),1,0) AS bdayage
FROM ClientInfo
WHERE (((Month([DOB]))=Month(Date())) AND ((Day([DOB])) Between
Day(Date())-5 And Day(Date())+5))
ORDER BY Month([DOB]), Day([DOB]);
Thanks
Barry
.
.