what if you really want to store the timestamp data, such
as the publication date of the article?

Answer Posted / tim little

A timestamp field can hold a date passed to it!
If you do :
CREATE TABLE newtable ( aname varchar(32), pubdate timestamp );
INSERT INTO newtable ( aname, pubdate ) values ( 'first', '2009-07-08' );
and then do a
SELECT * from newtable;

Then you get "2009-07-08 00:00:00" as the date back! You don't need a second field. Why do people think this? I've seen this all around the internet and it's always wrong!

Now, I will tell you that any updates to that ROW WILL clobber the field, UNLESS you make efforts to put the old value back in, like :
update newtable set aname = 'now', pubdate=pubdate where aname = 'first';

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I install mysql?

454


What are the differences between char and varchar data types?

488


What is latest version of mysql?

496


I want to start and stop mysql on windows? How do I do that?

512


What are the types of index?

502






What is mysql and how it works?

454


Does mysql automatically index foreign keys?

483


How do I transfer data from one database to another in mysql?

484


What is dirty read and phantom read?

437


how you will Create a database on the mysql server with unix shell.

548


What is mysql in dbms?

475


How do I start mysql server?

461


Consider you have the following three tables which have to be linked together.

484


What are stored procedures and functions?

464


How do I restore a mysql database dump file in linux?

477