473,327 Members | 1,896 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,327 software developers and data experts.

Mysql date problem

Hello everybody.
I took database course two years ago and I am having a serious problem.
I created a table called pet with mySQL 5.0 and it has 6 fields. Among them are two fields for birth Date and death Date.
When inserting the data I have one pet born today. I am trying to query the pet who was born today but it is not working. Here is my syntex
Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM pet
  3. WHERE birth Date = CURRENT_DATE( ) ; 
  4.  
I get a syntex error even when I use the CURDATE() function.

WHAT AM I DOING?
If this query works. I want to create a TABLE month with date field and message field. Then query it in such a way that each day the message automatically be displayed on our web site as a daily devotional. I do not know if it will work or not.
If there is anybody out there who can help me with the query above and may be another alternative of my goal please helo me.
Thanks
kyan
Sep 13 '07 #1
6 3137
r035198x
13,262 8TB
Hello everybody.
I took database course two years ago and I am having a serious problem.
I created a table called pet with mySQL 5.0 and it has 6 fields. Among them are two fields for birth Date and death Date.
When inserting the data I have one pet born today. I am trying to query the pet who was born today but it is not working. Here is my syntex
SELECT *
FROM pet
WHERE birth Date = CURRENT_DATE( ) ;
I get a syntex error even when I use the CURDATE() function.

WHAT AM I DOING?
If this query works. I want to create a TABLE month with date field and message field. Then query it in such a way that each day the message automatically be displayed on our web site as a daily devotional. I do not know if it will work or not.
If there is anybody out there who can help me with the query above and may be another alternative of my goal please helo me.
Thanks
kyan
What are your column datatypes?
It would help if you post the error message you are getting too.
Sep 13 '07 #2
Datatypes are (Name) varchar(20)
(birth Date) date

SQL query:
Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM `pet` 
  3. WHERE birth Date = CURDATE( ) 
  4. LIMIT 0 , 30 
  5.  
MySQL said:
Expand|Select|Wrap|Line Numbers
  1. #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Date = CURDATE( ) 
  2. LIMIT 0, 30' at line 1
  3.  
Sep 14 '07 #3
r035198x
13,262 8TB
Datatypes are (Name) varchar(20)
(birth Date) date

SQL query:

SELECT *
FROM `pet`
WHERE birth Date = CURDATE( )
LIMIT 0 , 30

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Date = CURDATE( )
LIMIT 0, 30' at line 1
Don't put a space between birth and date.
The column name should be BirthDate, one word.
Sep 14 '07 #4
Atli
5,058 Expert 4TB
Don't put a space between birth and date.
The column name should be BirthDate, one word.
I would recommend this as well, but if you insist on having spaces in you names, you can do so by encapsulating them in back-ticks. For example:
Expand|Select|Wrap|Line Numbers
  1. SELECT `My ID` FROM `My Table`;
  2.  
Sep 14 '07 #5
ronverdonk
4,258 Expert 4TB
Changed the thread title to better describe the problem.

moderator
Sep 15 '07 #6
Thank you
I removed the space betweb the birth Date and it worked
Sep 17 '07 #7

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

Similar topics

4
by: Dariusz | last post by:
I am a beginner in PHP and MySQL, and am working through a book and various online tutorials on PHP and MySQL and now stuck - installed everything on "localhost" and it all works fine. My question...
4
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I...
5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
0
by: Duane Winner | last post by:
Hello all - I'm having a small problem with the mysql startup script that ships with MySQL-3.23.56-1. I'm running on RedHat Linux. It works fine, but I have a backup server that runs a script...
10
by: Newsscanner | last post by:
Hello, In my MySQL database, one of the fields eople have to fill in is "DOB" (Date of Birth). I have now managed to begin inserting data into my DB via a form, the data type for the DOB field...
6
by: Piotr | last post by:
Hi, I have following problem: I use a form in excel to send data into mysql server, everything is ok unless I have to deal with decimals or data fields, this simple are not recognized. For...
0
by: nrip | last post by:
Dear All, I am facing a very peculiar problem. I am reading a CSV file from my JSP code and trying to insert them into MYSQL database. the program first reads a line and then splits it into words...
3
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running...
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
8
by: Tony B | last post by:
I have a string in a existing php script which is in the form "dd/mm/yyyy" and I need to convert it into a suitable format for mysql which is "yyyy-mm-dd" Is there a neat way of doing this in php ?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.