如何在mysql中两个日期之间获取日期? [英] how to get date between two dates in mysql?
本文介绍了如何在mysql中两个日期之间获取日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MySql数据库中,该表中的AM_TIMETABLE
表
In MySql database have AM_TIMETABLE
table in that
UserId DateTime
101 2012-08-08 04:00:00
102 2012-08-15 10:00:00
103 2012-08-18 09:00:00
104 2012-08-24 05:00:00
我的问题是,我要传递开始日期和结束日期,然后获得DateTime
列日期
例如:
My Question is, i'm passing start-date and end-date then i'll get DateTime
column date
for ex:
select * from AM_TIMETABLE where DateTime<='2012-08-08 00:00:00' and DateTime>='2012-08-20 00:00:00'
然后我将获得101,102,103 UserId的值.
但我出现错误please help
then i will get 101,102,103 UserId's value.
but i'm getting error please help
推荐答案
这可能会更好:
select * from AM_TIMETABLE where `DateTime`<='2012-08-20 00:00:00' and `DateTime`>='2012-08-08 00:00:00'
DateTime
也可能是保留字,对此不太确定.如果是这种情况,则您需要在其周围加上反引号(前后应有一个`)
DateTime
might also be a reserved word, not so sure about that. If that's the case, you need backticks around them (a single ` before and after)
这篇关于如何在mysql中两个日期之间获取日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文