Page 1 of 1

[SOLVED] adding a date in

Posted: Fri Jan 16, 2004 2:42 am
by nutstretch
I want to automatically add the today's date into a field on my database for DateEntered.

In access I just use the date() function as the default value in the field. Is there a similar function for mysql?

if not i can enter it when the other data is enterered but am unsure of the syntax. when i tried getdate() id didn't work do I need to put anything in the () part or am i completely barking up the wrong tree/

Any help appreciated

Posted: Fri Jan 16, 2004 3:14 am
by McGruff
Check out the mysql manual. The correct column type will add the current date automatically when a new row is created - you won't need to enter anything.

Posted: Fri Jan 16, 2004 5:42 am
by twigletmac

Posted: Fri Jan 16, 2004 5:47 am
by nutstretch
Thanks I also realised I was using the wrong datatype. changed the field to timestamp and it auitomatically gets entered.

Posted: Fri Jan 16, 2004 5:57 am
by rajshekhar
Small answer check out http://www.mysql.com/doc/en/DATETIME.html . Long answer, make a column of type TIMESTAMP. The TIMESTAMP column type provides a type that you can use to automatically mark INSERT or UPDATE operations with the current date and time. If you have multiple TIMESTAMP columns, only the first one is updated automatically.