| | |
Help with birthday MySQL Script
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Solved Threads: 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
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
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.
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.
Last edited by iamthwee; Jun 23rd, 2007 at 4:48 am.
*Voted best profile in the world*
•
•
•
•
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.

select DATE_ADD('2007-06-27',INTERVAL 1 DAY);See for further details...
http://dev.mysql.com/doc/refman/4.1/...nction_curdate
Last edited by iamthwee; Jun 24th, 2007 at 10:17 am.
*Voted best profile in the world*
Maybe you could use something like:
perhaps?
The ending date could be got by using the data_add (14 days) to the current date.
MySQL Syntax (Toggle Plain Text)
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.
Last edited by iamthwee; Sep 30th, 2007 at 10:51 am.
*Voted best profile in the world*
![]() |
Similar Threads
- Traffic Exchange (PHP)
- MySql file (MySQL)
- PHP Confirm Delete (PHP)
- what to do with this .SQL script? (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: Indexing and Query optimisation.
- Next Thread: Trigger problem...
Views: 3877 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for MySQL
"use" 1 agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design development distinct drupal ec2 eliminate email enter enterprise error eudora facebook form foss gartner gnu gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keywords kickfire laptop law linux maintenance managing mariadb metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlquery mysqlsearch news open-xchange opendatabasealliance opensource operand oracle pdf php priceupdating query referencedesign remove reorderingcolumns results resultset saas search sharepoint simpledb sourcecode spotify sql statement sugarcrm syntax techsupport transparency update






