473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

upcoming birthdays query

Hi

I have a database birthday containing name and DOB,
I want to find the query which can display 3 latest birth day.

I tried
select name,date from birthday where month(dob)>=month(curdate()) limit 3;

But the problem here is that on 31-December-2008 it will not display the birthdays on January.

Shashank
Oct 30 '08 #1
6 7562
r035198x
13,262 8TB
Why are you taking the month parts?
Try something like
Expand|Select|Wrap|Line Numbers
  1. where dob >= curdate() order by dob limit 3;
Oct 30 '08 #2
Why are you taking the month parts?
Try something like
Expand|Select|Wrap|Line Numbers
  1. where dob >= curdate() order by dob limit 3;
Problem with it is:

If Current date is 31 december 08

then it will not display birthday in the moth if january 09

Also dob can never be more than currdate( )

MY dob is 28-08-1986(suppose) it cant be greater than currdate( )
Oct 30 '08 #3
for it we have to use three query subsequently

1) select name,date from days_to_remember where month(date)=month(curdate()) AND date(date)>=date(curdate()) order by date asc;

-----it will give upcomng bdays of same months---



2) select name,date from days_to_remember where month(date)>month(curdate()) order by date asc;

-----it will give upcomng bdays of next months---

3) select name,date from days_to_remember order by date asc;

-----it will give upcomng bdays of next year---


use a counter element to limit the number of elements
Oct 30 '08 #4
r035198x
13,262 8TB
Problem with it is:

If Current date is 31 december 08

then it will not display birthday in the moth if january 09

Also dob can never be more than currdate( )

MY dob is 28-08-1986(suppose) it cant be greater than currdate( )
Oh silly me. I get your point now. The year part should not be included in the comparison.
Oct 30 '08 #5
Oh silly me. I get your point now. The year part should not be included in the comparison.
thats correct
but
we do have to take into cosideration the year when the current date is
31-dec-2008..

the above 3 queries that i have given will do that perfectly
Oct 31 '08 #6
great
Thanks a lot.
Aug 4 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stijn Goris | last post by:
hi all, I have this problem that I cant solve. I have created an agenda (http://28edegem.scoutnet.be/agenda.php) . The agenda contains events and birthdays of the members. I query the events...
0
by: Joel Burton | last post by:
The newly-formed Zope/Python Users Group of DC announces our upcoming meeting schedule: Mo Jul 19: Zope -- presentation on Archetypes by Joel Burton Th Aug 5: Python -- no topic yet Mo Aug...
1
by: JR | last post by:
Hi -- I would like to know if it is possible to program Access to notify a user of an upcoming date. For example, in a database of people, if one has a final report in 30 days, can Access be...
0
by: Nick White [MSFT] | last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts: I invite you to peruse the list below of upcoming technical chats and Webcasts offered by the Windows Mobile and Embedded Devices...
0
by: Nick White [MSFT] | last post by:
Hello fellow Windows Mobile and Embedded enthusiasts: Allow me to direct your attention to the list below of upcoming Windows Mobile and Embedded product chats and Webcasts. I invite you to...
26
by: Yeah | last post by:
I have a web site which changes the header logo based on the upcoming holiday. For example, from December 10th to 25th, XMAS.JPG is displayed. From October 20th to 31st, HALLWEEN.JPG is...
1
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
3
by: Bo Wisén | last post by:
In a MYSQL database I have stored when the members were born in the form "YYYYMMDD". Now I want a method to select every member who has birthday from today and up to 30 days into the future. I...
6
by: schlow09 | last post by:
I have been trying to automate certain steps in this database for a company I am working with. I would like to have a query or report run automatically at startup showing all the records that have a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.