MySQL 中下一个最近的日期和时间 [英] Next closest date and time in MySQL
本文介绍了MySQL 中下一个最近的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 Auctions
表中,有一列名为 Auction_StartDate
.一行的值是这样的:2012-10-27 13:45:30
.
Inside of my Auctions
table, I have a column called Auction_StartDate
. The value of a row is like this: 2012-10-27 13:45:30
.
我需要一个查询,在此之后返回下一个最接近的日期和时间.所以如果下一个 Auction_StartDate 是 2012-10-27 18:30:00
,它应该在日期变成 2012-10-28
之前返回那个.
I need a query that will return the next closest date and time after that. So if the next Auction_StartDate is 2012-10-27 18:30:00
, it should return that before the date turns to 2012-10-28
.
推荐答案
也许这个有帮助
SELECT DATE(Auction_StartDate) closestDate
FROM Auctions
WHERE DATE(Auction_StartDate) > '2012-10-27'
order by Auction_StartDate ASC
limit 1
这篇关于MySQL 中下一个最近的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文