Birthday problem - Help me

sougata

Registered User.
Local time
Today, 16:52
Joined
Dec 26, 2006
Messages
11
I have a table with 3 fields-

empid
empname
empbday

now I want to display upcoming birthdays of employees [eg- in next 7 days]

plz help
 
this looks messy but should work :)
assuming your table is called tbl

SELECT tbl.empid, tbl.empname, tbl.empbday, IIf(DateSerial(Year(Date()),Month([empbday]),Day([empbday]))<Date(),DateSerial(Year(Date())+1,Month([empbday]),Day([empbday])),DateSerial(Year(Date()),Month([empbday]),Day([empbday]))) AS checkDate
FROM tbl
WHERE (((IIf(DateSerial(Year(Date()),Month([empbday]),Day([empbday]))<Date(),DateSerial(Year(Date())+1,Month([empbday]),Day([empbday])),DateSerial(Year(Date()),Month([empbday]),Day([empbday]))))<Date()+7));


Peter
 
Thanksssssssssssssssssssssssssss


its working
 
I another question -

I got error when the record is null, how could I bypass the error
 
ok, try
SELECT tbl.empid, tbl.empname, tbl.empbday
FROM tbl
WHERE (((IIf(IsNull([empbday]),Date()+8,IIf(DateSerial(Year(Date()),Month([empbday]),Day([empbday]))<Date(),DateSerial(Year(Date())+1,Month([empbday]),Day([empbday])),DateSerial(Year(Date()),Month([empbday]),Day([empbday])))))<Date()+7));


Peter
 
Hello Peter,

Thank you very much

its again working :)
 

Users who are viewing this thread

Back
Top Bottom