Re: Echo date in dd-mm--yy format
It's an error to store datetimes or timestamps in MySQL in "dd-MM-yyyy hh:mm:ss" format. MySQL datetime arithmetic is designed to work only with the universal "yyyy-mm-dd hh-mm-ss" format; other formats should be transformed to that using the MySQL str_to_date() function.
Your table probably stores these values in a string or text column. That severely limits their functionality. You need to replace such columns with timestamp or datetime columns populated with values generated by str_to_date() calls like str_to_date( "17-08-2022 01:02:03", "%d-%m-%Y %h:%i:%s" ), which in that example returns the valid datetime or timestamp value 2022-08-17 01:02:03. Querying that column will return that value in that format. <correction> Use date_format() to modify display format (see the manual page for that func) </correction>.
Edited 1 time(s). Last edit at 08/18/2022 10:34PM by Peter Brawley.
Subject
Written By
Posted
Re: Echo date in dd-mm--yy format
August 17, 2022 01:04PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.