Comments - Insert into table using select based on date does not work
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
Your example seems to contain microseconds, but you do not cater for this in your formatting. Even the original query gives a warning in this case:
select STR_TO_DATE('20200809 020917076','%Y%m%d %H%i%s'); +---------------------------------------------------+ | STR_TO_DATE('20200809 020917076','%Y%m%d %H%i%s') | +---------------------------------------------------+ | 2020-08-09 02:09:17 | +---------------------------------------------------+ 1 row in set, 1 warning (0.000 sec) Warning (Code 1292): Truncated incorrect datetime value: '20200809 020917076'You can use
%fto format for microseconds.select STR_TO_DATE('20200809 020917076','%Y%m%d %H%i%s%f'); +-----------------------------------------------------+ | STR_TO_DATE('20200809 020917076','%Y%m%d %H%i%s%f') | +-----------------------------------------------------+ | 2020-08-09 02:09:17.076000 | +-----------------------------------------------------+