In MySQL I want the current date as my default and not the time.
CREATE TABLE Order_T
(OrderID NUMERIC(11) NOT NULL,
OrderDate DATE DEFAULT NOW(),
CustomerID NUMERIC(11),
CONSTRAINT Order_PK PRIMARY KEY (OrderID),
CONSTRAINT Order_FK FOREIGN KEY (CustomerID) REFERENCES Customer_T (CustomerID));
I dont know why this doesn't work for the date.
I want the default date to be current date without the time stamp.
use a trigger
DELIMITER ||
CREATE TRIGGER curr_date BEFORE INSERT ON Order_T FOR EACH ROW
BEGIN
SET new.date = NOW();
END ||
DELIMITER ;
see this answer How to set default value of MySQL DateTime ( not TIMESTAMP ) to NOW() or Current_DateTIme?t-value-of-mysql-datetime-not-timestamp-to-now-or-current