Link to home
Start Free TrialLog in
Avatar of godwindotnet
godwindotnet

asked on

Querying dates

Hello,
I want to create a program to remind people of their birthdays 5 days before their birthday..everyday till their birthday pasees by.
I have a list of records with peoples birthdays on sqlserver database.I want to set a reminder of peoples birthdays 5 days before their birthday.I want to be reminded on every one of those 5 days till their birthdays ends.How should the query be? Please help,
Thanks.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

what database?
table structure?
Avatar of godwindotnet
godwindotnet

ASKER

Just imagine there are 5 columns in a database and one column is the birthday column where the persons birth date is stored.
Now,there are probably 1000s of records in the database.(Just keep the birthday column in mind,forget what other columns are...im just saying this as an example for what i want to implement in my project.)
I want to send queries everyday and i want to send reminders(imagine im sending reminder emails to myself) 5 days before anyones birthday approaches.
On every one of those 5 days,i want to be reminded till.... their birthday is over.

Im using sqlserver 2005 express as database.Vb.net as front end.
And Thanks for the quick response Angel...it was just 2 minutes after i posted...:-)


select * from yourtable
where convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 5, getdate()), 101)
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Give me few minutes angel..Ill try this what youve given with my program and getback
to make the above performant, you should make a computed field on your table containing the value of
convert(varchar(5), birthdate , 101)
+put an index on that field
+use that field instead of the convert()... in the query
You deserve 2000 pointrs,but EE lets me give only 500 :-(
Thanks a tonne for that answer and for the time you took for me :-)
actually, with the grade A, I got 2000 points (500x4)
Glad I could help