MySQL中的特定日期格式 [英] Specific Date Format in mysql
本文介绍了MySQL中的特定日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用MySQL
表
ID Date
001 2010-05-01
002 2010-06-08
查询
Select ID, Date from table;
我想以特定格式显示日期
I want to display a date in a specific format
预期产量
ID Date
001 01-Mar-2010
002 08-June-2010
如何在mysql中进行查询.
How to make a query in mysql.
需要查询帮助
推荐答案
You can use DATE_FORMAT with the format string '%d-%M-%Y'.
CREATE TABLE table1(ID varchar(100), Date datetime);
INSERT INTO table1 VALUES
('001', '2010-05-01'),
('002', '2010-06-08');
SELECT ID, DATE_FORMAT(Date, '%d-%M-%Y') FROM table1;
结果:
ID Date
001 01-May-2010
002 08-June-2010
这篇关于MySQL中的特定日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文