Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select issue. MySql to_day( ) ???

Status
Not open for further replies.

felix1the2cat

Programmer
Feb 8, 2005
6
US
Hi Guys.. I am running SQLyog with MYSQL. SQLyog is a GUI for Mysql connection. You can run SQL command inside the GUI.

I would like to select all information that was inserted into the database from 1/1/2005 till now. I am using

select * from `testingTable`.`customers` where date_cr > to_date('20050101'YYYYMMDD')

But the command didn't work. Can someone tell me the correct format for this???

Thanks
 
I need to select the records starting from 2005-01-01 to 2005-02-08 or Now();
But I am not familiar with Mysql command.



This is the error I got.

select * from `DB1`.`customers` where date_cr > to_date('20050101' 'YYYYMMDD')

Error Code : 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 '('20050101' 'YYYYMMDD')' at line 1
(62 ms taken)

I am not sure if this a correct command / format. Does MYSQL has to_day() function???

Thanks...
 
'20050101' 'YYYYMMDD' is not what you had in your first post. Proper typing is important in programming and in forums.

The next obvious problem is that your function arguments should be comma delimited, i.e. ('20050101', 'YYYYMMDD')
 
Hi Ericbrunson

I fixed the , error, but it still giving me an error. I am new to Mysql, a friend of mine who uses Oracle asked me to try to_day( ) function. But it doesn't seem to be working.

select * from `DB1`.`customers` where date_cr > to_date('20050101','YYYYMMDD')

Error Code : 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 '('20050101','YYYYMMDD')' at line 1
(62 ms taken)

My really question is what Mysql function i should use??
 
Hi Ericbrunson

I fixed the , error, but it still giving me an error. I am new to Mysql, a friend of mine who uses Oracle asked me to try to_day( ) function. But it doesn't seem to be working.

select * from `DB1`.`customers` where date_cr > to_date('20050101','YYYYMMDD')

Error Code : 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 '('20050101','YYYYMMDD')' at line 1
(62 ms taken)

My really question is what Mysql function/command I should use to get the result I want!

 
In MySQL, dates must be specified in the form 'yyyy-mm-dd' or 'yyyymmdd' or yyyymmdd, so your comparison should be:
[tt] WHERE date_cr >= '2005-01-01'[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top