Is there a way in my sql to auto increment by the date and time?
so say I have a table
mytable
============================
Run this in your MySQL:
ALTER TABLE `mytable`
CHANGE COLUMN `DateTime` `DateTime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ;
This sets your default value to CURRENT_TIMESTAMP
.
You can set a default value for your datetime column, now()
. This way whenever you add a row, it will automatically get current datetime.