944,175 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 4266
  • MySQL RSS
Nov 6th, 2006
0

Sql Query Help

Expand Post »
Hello,

I am developing a simple calender in my site which will display the next upcoming birthday of my member.

I have a table which has 2 column


cname | dob
-------------------
Joe | 9/12/1982
Mathew | 2/17/1997
Pat | 8/23/1880
-------------------

What SQL Query should I use to get the name of that person?
Similar Threads
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Nov 7th, 2006
0

Re: Sql Query Help

Hi, i think the following should help / give you an idea (eg retrieves names of members whose dob falls in current month--according to system date)

select cname from tablename wherE
datepart (mm,convert(datetime,dob))
= (select datepart(mm,convert(datetime,getdate())) )
Reputation Points: 10
Solved Threads: 0
Light Poster
sierrasoft is offline Offline
31 posts
since Nov 2006
Nov 7th, 2006
0

Re: Sql Query Help

Thanx but it generates this error

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error. in query expression 'datepart (mm,convert(datetime,dob)) = (select datepart(mm,convert(datetime,getdate())))'
Last edited by cancer10; Nov 7th, 2006 at 11:23 am.
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Nov 7th, 2006
0

Re: Sql Query Help

Are you using Access and Jet?
Datepart will not work--it works only with SQL Server
Reputation Points: 10
Solved Threads: 0
Light Poster
sierrasoft is offline Offline
31 posts
since Nov 2006
Nov 8th, 2006
0

Re: Sql Query Help

Yes I am using Access and Jet

Any other solution?
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Dec 8th, 2006
0

Re: Sql Query Help

Click to Expand / Collapse  Quote originally posted by cancer10 ...
Yes I am using Access and Jet

Any other solution?
suppliment his solution a little. what language are you using to build the database. you may be suited to just use that language to get the current date and then pass that into the query.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: PHP Form, SQL connectivity issues, please help.
Next Thread in MySQL Forum Timeline: Change MySQL Query Timeout Period





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC