I’m in phpmyadmin right now and I am trying to set a field to stamp the current date when data is inserted.
Now I tried setting it to DATETIME type, but that includes time. I just want date. I also tried setting it to DATETIME with the default value to GETDATE() and saving but it threw an error:
#1067 - Invalid default value for 'upload_date'
Anyone know how to do this please?
Unfortunately, you can’t set the
DEFAULTvalue to a function, it needs to be a constant value. One exception isCURRENT_TIMESTAMP, although it will also include thetimepart:However, you can use a
TRIGGERto set the column’s default value. For example:Also, use
DATE()to truncate theTIMEpart ofNOW().