[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

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.
0
godwindotnet
Asked:
godwindotnet
  • 5
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what database?
table structure?
0
 
godwindotnetAuthor Commented:
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.
0
 
godwindotnetAuthor Commented:
And Thanks for the quick response Angel...it was just 2 minutes after i posted...:-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:


select * from yourtable
where convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 5, getdate()), 101)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>On every one of those 5 days,i want to be reminded till.... their birthday is over.


select * from yourtable
where convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 5, getdate()), 101)
or convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 4, getdate()), 101)
or convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 3, getdate()), 101)
or convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 2, getdate()), 101)
or convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 1, getdate()), 101)
or convert(varchar(5), birthdate , 101) = convert(varchar(5), dateadd(day, 0, getdate()), 101)
0
 
godwindotnetAuthor Commented:
Give me few minutes angel..Ill try this what youve given with my program and getback
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
0
 
godwindotnetAuthor Commented:
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 :-)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
actually, with the grade A, I got 2000 points (500x4)
Glad I could help
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now