Jump to content

Incorrect datetime value: '2022-01-24T20:52:00.000Z' for function str_to_date

Go to solution Solved by AJM2,

Recommended Posts

Error: INSERT INTO weather_data (datetime, temp, feelslike, stationbarometer, sealevelbarometer, dewpoint, humidity, winddir, windspeed, gust, maxdailygust, hourlyrainrate, dailyrain, weeklyrain, monthlyrain, totalrain, lastrain, solar, battout) VALUES ( STR_TO_DATE('2022-01-24T20:52:00.000Z' , '%c-%e-%Y %T'), 49.1, 49.1, 29.959, 29.135, 47.16, 93, 274, 0.7, 1.1, 8.1, 0, 0.181, 0.181, 0.701, 49.043, STR_TO_DATE('2022-01-24T19:22:00.000Z', '%c-%e-%Y %T'), 57.62, 1 )
Incorrect datetime value: '2022-01-24T20:52:00.000Z' for function str_to_date 

WTF is up with dates in mysql? I haven't worked in it since version 5.* but I never had the problems I am having trying to insert.

Any help would be greatly appreciated.


Link to comment
Share on other sites

If the field is a date then it should be a date. Don't make it a string.

But what I was trying to point out was that you were asking MySQL to interpret the timestamp 2022-01-22T20:52:00.000Z according to the format %c-%e-%Y %T, or in other words M-D-YYYY HH:MM:SS. That's not going to work.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.