0

Ok this is what my table structure looks like:
username varchar(20)
eadd varchar(40) for email addresses
bday varchar(4) everyone is posting mmdd
emailques varchar(2) they answer yes or no
I want my query statement to tell me what birthdays are today and as a bonus email them on their birthday.
I tried:
select * from lpbdays where bday = curdate();

That didn't work the closest I got was when I did:
select * from lpdays where bday = 0622 (if I do it manually);

If anyone out there can help me out on this that would be great.

Thanks,
Elderp

3
Contributors
7
Replies
8
Views
10 Years
Discussion Span
Last Post by iamthwee
0

I guess this is a problem with data types.

Try looking here. Curdate should return something like 2004-11-30. Date variables and string (varchars) cannot be compared directly.

You are storing your dates as 0622. So first you would have to convert the curdate() to a string, strip it of the hypens and take of the year.

0

Thanks for the help, I actually did solve this issue (with some help from a European Discussion Board).
Here was my solution:
select * from lpbdays where bday =date_format(now(),'%m%d');

0

Anyone know or have an idea how I can change this query so it will give me a result one day from now. For example I want it to give me a list of all the birthdays that will happen tommorow that way I can prepare for them.

0

Anyone know or have an idea how I can change this query so it will give me a result one day from now. For example I want it to give me a list of all the birthdays that will happen tommorow that way I can prepare for them.

I don't see why you would need to prepare this in advance. Databases are real time apps ya know. :)

select DATE_ADD('2007-06-27',INTERVAL 1 DAY);

See for further details...
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_curdate

0

Found a super simple solution:
select * from lpbdays where bday =(date_format(now(),\'%m%d\')+1)';

0

I have a similar situation but I am storing my birthday as a date format yyyy-mm-dd. I need to search for birthdays from the current day up to 2 weeks. Thank you.

0

Maybe you could use something like:

SELECT <whatever> FROM <TABLE_NAME> WHERE date >= 'starting date' AND date < 'ending date'

perhaps?

The ending date could be got by using the data_add (14 days) to the current date.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.