How to change SQL date format to YYYY-MM-DD?
P粉713846879
P粉713846879 2024-01-04 16:42:59
0
1
550

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粉713846879
P粉713846879

reply all(1)
P粉021854777

You can use the DATE_FORMAT function to format dates.

SELECT DATE_FORMAT(start_date, '%Y-%m-%d') FROM table_name;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!