I have a column named "start_date" with data type "DATE". On my database table it appears as "YYYY-MM-DD" format, but when I pull the data from the project (using node.js) I get the result as "YYYY-MM-DDT22:00:00.000 Z". How do I change the format to "YYYY-MM-DD"? I tried FORMAT(start_date, "yyyy-MM-dd") but it didn't work...
I know we can usually change the format from client side using moment like moment(start_date).format("YYYY-MM-DD") but I am trying to do this from server side. p>
P粉0218547772024-01-05 14:50:31
You can use the DATE_FORMAT
function to format dates.
SELECT DATE_FORMAT(start_date, '%Y-%m-%d') FROM table_name;