In my sql query, I am getting the output as below.
insert into terminationdata (Name,Date,Calls,Answered_Calls,Total_Minutes) values('XXX',2021-12-17,'480298','120758.0','391238.6333') ON DUPLICATE KEY UPDATE name=VALUES(name),Date=VALUES(Date),calls=VALUES(calls),Answered_Calls=VALUES(Answered_Calls),Total_Minutes=VALUES(Total_Minutes)
I have created a new table as below to save all the data.
create table terminationdata(
Name VARCHAR(20) NULL ,
Date DATETIME NULL ,
Calls INT NULL DEFAULT '0',
Answered_Calls INT NULL DEFAULT '0',
Total_Minutes DECIMAL(8,2) NULL
);
The query is working fine but the date is not correctly fetched in table. In table the date is shown as 0000-00-00 00:00:00
. How should I get the correct date(ex-2021/12/19)?
I have tried Date DATE NULL
instead of Date DATETIME NULL
.But the same error is there.
CodePudding user response:
encapsulate your datetime
value with single quotes. It will be automatically cast to datetime
(if your string value is a valid datetime).
insert into terminationdata (Name,Date,Calls,Answered_Calls,Total_Minutes) values('XXX','2021-12-17','480298','120758.0','391238.6333') ON DUPLICATE KEY UPDATE name=VALUES(name),Date=VALUES(Date),calls=VALUES(calls),Answered_Calls=VALUES(Answered_Calls),Total_Minutes=VALUES(Total_Minutes)