mysqldatedayofmonth

When i Create table with Month he only given 0000-00-00


I create table for hour

CREATE TABLE hour (
    Name1 varchar(25) not null,
    Datee Datetime not null DEFAULT (CURRENT_TIMESTAMP()),
    Monthh date not null DEFAULT (MONTH(CURRENT_DATE()))
);

Mysql only give me 0000-00-00 not Name where i use button in php. What is wrong with this and how correct? In my opinion my phpadmin dont have a MONTH function


Solution

  • CREATE TABLE hour ( Name1 varchar(25) not null,
                        Datee DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
                        Monthh TINYINT NOT NULL DEFAULT (MONTH(CURRENT_TIMESTAMP))
                      );
    

    fiddle

    PS. HOUR is Reserved word - I'd recommend to rename a table.