MySQL Insert satement

I have a table that has a time stamp value that is set as a varchar.

I have created another table with a date value, I want to to convert the time stamp value into a date format and insert the rows into the new table.

Below is the statement I have written. I assumed by converting to a "DATE_FORMAT the receiving table would except the rows.

INSERT INTO tblCards_Status  (TransferStatus)
SELECT  DATE_FORMAT(TransferStatus, '%d/%m/%Y') AS TransferStatus
FROM    tblcards
WHERE TransferStatus IS NOT NULL
ORDER BY TransferStatus DESC

Open in new window


I am getting the following error message

Error Code: 1292. Incorrect date value: '31/10/2012' for column 'TransferStatus' at row 1
BrogrimInformation Systems Development ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dipopoCommented:
HI there have you tried

SELECT  DATE_FORMAT(TransferStatus, '%dd/%mm/%YYYY') AS TransferStatus
0
BrogrimInformation Systems Development ManagerAuthor Commented:
It is now returning

Error Code: 1292. Incorrect date value: '31d/10m/2012YYY' for column 'TransferStatus' at row 1
0
dipopoCommented:
Opps my bad please try this then.

SELECT  DATE_FORMAT(TransferStatus, 'yyyy/MM/dd') AS TransferStatus
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

BrogrimInformation Systems Development ManagerAuthor Commented:
I am now getting:

Error Code: 1292. Incorrect date value: 'yyyy/MM/dd' for column 'TransferStatus' at row 1

I changed to

SELECT  DATE_FORMAT(TransferStatus, 'dd/mm/yyyy') AS TransferStatus

same result

Error Code: 1292. Incorrect date value: 'dd/mm/yyyy' for column 'TransferStatus' at row 1
0
dipopoCommented:
Could you select all from that column, need to see present format. limit to 10.
0
BrogrimInformation Systems Development ManagerAuthor Commented:
I have managed to get that Transferstatus inserted into the records using
DATE_FORMAT(TransferStatus, '%Y/%m/%d') AS TransferStatus

Open in new window


This is beacuse the time stamp is formatted as '2013/09/09 20:39:40'

I am now trying to include another column "PrintStatusFront" but the timestamp on this one is '2013/09/10 10:20 '

The seconds is not included.

Any Idea how I can get this one inserted.
0
BrogrimInformation Systems Development ManagerAuthor Commented:
Had to change it around a little but you put me on the right track, thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.