I want to set date as default value for date in mysql (not timestamp), but the following error appear
ALTER TABLE `RMS`.`transactionentry`
CHANGE `Date` `Date` DATE DEFAULT NOW() NOT NULL
Error
Invalid default value for 'Date'
Same Case
alter table `RMS`.`transactionentry`
change `Date` `Date` date default 'CURRENT_DATE' NOT NULL
alter table `RMS`.`transactionentry`
change `Date` `Date` date default current_timestamp NOT NULL
I don't think you can achieve that with mysql date
. You have to use timestamp
or try this approach..
CREATE TRIGGER transactionentry_OnInsert BEFORE INSERT ON `RMS`.`transactionentry`
FOR EACH ROW SET NEW.dateColumn = IFNULL(NEW.dateColumn, NOW());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With