• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

[sql] date stamping

Question

asy1mpo    0

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

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
asy1mpo    0

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'

Share this post


Link to post
Share on other sites
  • 0
Kami-    178

I'll go with your using MySQL, and in which case instead of timestamp, can't you use date when creating the table?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.