yyyy-mm-dd hh:mm:ss 转换 mysql date,在MySQL中仅从日期时间(YYYY-MM-DD HH:MM:SS)中按日期选择不同的日期...

Executing this command brings me the following (all the dates from all columns, so it essentially did the same thing as SELECT date without distinct):

SELECT DISTINCT date FROM daily ORDER BY date DESC

2013-02-12 16:40:52

2013-02-06 11:48:49

2013-02-06 11:36:41

2013-02-06 11:35:59

2013-02-04 19:38:12

2013-02-04 18:12:30

2013-02-04 09:58:41

2013-02-04 09:43:01

2013-02-04 09:35:51

2013-02-04 09:30:22

2013-02-04 09:24:57

2013-02-04 09:21:09

2013-02-04 08:50:13

What I need:

2013-02-12

2013-02-06

2013-02-04

Is there any way to alter my date table and convert it to YYYY-MM-DD instead?

If not, is there a way to select distinct dates based only on the day?

解决方案mysql> select DATE_FORMAT(Current_Timestamp, '%c %d %Y') from dual;

+--------------------------------------------+

| DATE_FORMAT(Current_Timestamp, '%c %d %Y') |

+--------------------------------------------+

| 2 12 2013 |

+--------------------------------------------+

1 row in set (0.01 sec)

mysql>

of course you would be using your 'daily' table.

mysql> select DATE_FORMAT(Date, '%c %d %Y') from daily;

or maybe you want

mysql> select * from daily group by DATE_FORMAT(Date, '%c %d %Y');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值