Wednesday, January 15, 2025
HomeProgrammingHow can I format a DATETIME value in MySQL to display as...

How can I format a DATETIME value in MySQL to display as ‘DD-MM-YYYY HH:MM:SS’?

To format a DATETIME value in MySQL as ‘DD-MM-YYYY HH:MM:SS’, you can use the DATE_FORMAT function. Here’s an example:

 

sqlCopy code

SELECT DATE_FORMAT(your_datetime_column, ‘%d-%m-%Y %H:%i:%s’) AS formatted_datetime

FROM your_table;

Explanation of the format specifiers:

%d: Day (two digits, zero-padded).

See also  How do you implement a Stack and a Queue in JavaScript?

%m: Month (two digits, zero-padded).

%Y: Year (four digits).

%H: Hour (24-hour format, two digits).

%i: Minutes (two digits).

%s: Seconds (two digits).

Replace your_datetime_column and your_table with your actual column and table names.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x