September 13th, 1999, 03:09 PM
is there a way to set the default for a column to be the current date, without making that column a timestamp? i'm trying to provide the current date as the starting point for a column that will ultimately be changed. it seems that if mysql would accept multiple select statements, i should be able to do it with the following syntax:
ALTER table paintings ALTER column creation_date SET DEFAULT (select current_date());
September 13th, 1999, 07:59 PM
Use the now() function as your default:
ALTER TABLE paintings CHANGE creation_date creation_date DATETIME DEFAULT 'now()' not null';
now() gives the current date & time.
[This message has been edited by netman (edited 09-13-99).]
September 13th, 1999, 09:11 PM
that SQL statement doesn't work - it produces a default of 0000-00-00 00:00:00
September 14th, 1999, 05:39 PM
Sorry... I tested this out with phpMyAdmin and phpMyAdmin automatically defaults the date to the current date.
February 12th, 2010, 06:01 PM
i believe i am having a similar problem... i need to set my default value to a function as well, but pma seems to have none of this. is there perhaps any way to have it done via the mysql console?
i need to set the default value of a timestamp field to CONVERT_TZ(CURRENT_TIMESTAMP, 'SYSTEM', '+2:00'), the following select statement works in PMA to change the timezone...
if i uncheck the timestamp mark, and insert the CONVERT_TZ function as used above into the default field in phpMyAdmin, it sets the default time to 0000-00-00 00:00:00 as yours does... :/ i guess one cannot add functions to default values, yet this page says you can:
SELECT CONVERT_TZ(CURRENT_TIMESTAMP, 'SYSTEM', '+2:00') AS timestamp_SAST;
Comments on this post
Last edited by buggers; February 12th, 2010 at 10:04 PM.
February 12th, 2010, 07:46 PM
buggers, please always check da manual before posting
as late as version 5, it says