asy1mpo Posted December 3, 2008 Share Posted December 3, 2008 I have some SQL code which has created a table in MySQL CREATE TABLE merchants ( merchantid int(11) NOT NULL auto_increment PRIMARY KEY, merchantname varchar(255) NOT NULL, merchanturl varchar(255) NOT NULL, categoryid int(11) NOT NULL, merchantdateadded timestamp(14) NOT NULL The timestamp automatically added the date/time when the data is added to table. The format of the timestamp is something like: 2008-12-03 22:59:14 What I want is just the date e.g. 2008-12-03 How can this be done?? Thanks Link to comment Share on other sites More sharing options...
0 asy1mpo Posted December 3, 2008 Author Share Posted December 3, 2008 its ok, figured out that i needed to change the actual sql query the code is now something like: $sql = "SELECT * FROM vouchers WHERE date(dateadded) = '2008-12-04' Link to comment Share on other sites More sharing options...
0 Kami- Posted December 4, 2008 Share Posted December 4, 2008 I'll go with your using MySQL, and in which case instead of timestamp, can't you use date when creating the table? Link to comment Share on other sites More sharing options...
Question
asy1mpo
I have some SQL code which has created a table in MySQL
CREATE TABLE merchants (
merchantid int(11) NOT NULL auto_increment PRIMARY KEY,
merchantname varchar(255) NOT NULL,
merchanturl varchar(255) NOT NULL,
categoryid int(11) NOT NULL,
merchantdateadded timestamp(14) NOT NULL
The timestamp automatically added the date/time when the data is added to table. The format of the timestamp is something like:
2008-12-03 22:59:14
What I want is just the date
e.g.
2008-12-03
How can this be done??
Thanks
Link to comment
Share on other sites
2 answers to this question
Recommended Posts