在mysql中获取时间戳的开始和结束 [英] Get the Start and End of the Day in timestamp in mysql

查看:525
本文介绍了在mysql中获取时间戳的开始和结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取时间戳的开始和结束时间?

How can I get the start and end of the day in timestamp?

输出如下:

04/01/2014 00:00:00

04/01/2014 23:59:59


推荐答案

也许有更好的方法,但是我认为这应该可行。

There probably is a better way to do it but I think this should work.

SELECT 
  DATE_FORMAT(CONCAT(CURDATE(), ' 00:00:00'), '%m/%d/%Y %H:%i:%s') as morning,
  DATE_FORMAT(CONCAT(CURDATE(), ' 23:59:59'), '%m/%d/%Y %H:%i:%s') as evening

SQL小提琴

这篇关于在mysql中获取时间戳的开始和结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆