Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need Query to select birthday  in dttime format

Posted on 2003-02-28
6
Medium Priority
?
438 Views
Last Modified: 2012-06-27
Hello All,

Im very much a newbie, so forgive me if this sounds dumb, but I have a problem with what seems like it should be a simple query.

I have MS SQL 7 running, and I have a table with a dttime value column named 'DOB' with birthdays in it. I want to write a script that querys the database daily to create a recordset of users in that database who have a birthday equal to the current date. To do this, I would need to wildcard a date query so it only looks for the month and date, but not year.

I know I can use a LIKE statement to find everyone with a birthday in a specific MONTH, but how can I combine the date with that also? Can anyone help me?

0
Comment
Question by:IT Gal
  • 2
  • 2
  • 2
6 Comments
 

Expert Comment

by:ramaswamy_ravi
ID: 8045101
select MONTH(DOB) = MONTH(GETDATE() AND DAY(DOB) = DAY(GETDATE()) FROM Table1

Ravi
0
 

Author Comment

by:IT Gal
ID: 8057711
I couldnt get this statement to work, but I did finally get this one to do what I wanted it to:

SELECT * FROM MEMBERS WHERE DATEPART(MONTH,DOB) = 1 AND DATEPART(DAY,DOB) = 1

Which I guess is more or less the same thing.

Now does anyone know how I can make that execute in a vbscript so that the month and day values are automatically filled in with the current month value and the current date value so it can be passed to the SQL database to return a recordset? Just curious.
0
 

Expert Comment

by:ramaswamy_ravi
ID: 8058966
I think there is asyntax error in the SQL
select MONTH(DOB) = MONTH(GETDATE()) AND DAY(DOB) = DAY(GETDATE()) FROM Table1

Try this. In any case, from VB Script u need to set up a connection and create a record set

In an earlier question, I have given the sample code.

Ravi
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:IT Gal
ID: 8059407
This is how I ended up doing it and it seems to work well.

SELECT * FROM MEMBERS WHERE DATEPART(MONTH, DOB) = DATEPART(month, GETDATE()) AND DATEPART(DAY, DOB) = DATEPART(day, GETDATE())

Thanks for your help!
0
 

Expert Comment

by:modulo
ID: 8263622
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/Q_20573332.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8278639
Saving this Q as a PAQ and refunding the 50 points to the questionner

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question