PL/SQL(oracle)中按天查询
我正在从数据库查询:
select * from database where id = 12345
我得到了几天它等于 3/4/2010 9:16:59 AM
但如果我添加 和 date = to_date('03/04/2010','DD/MM/YYYY')
让我
select * from database where id = 12345
and date = to_date('03/04/2010','DD/MM/YYYY')
什么也没回来。
有什么指点吗? 顺便说一句,我知道那里有一个时间,但我不知道如何根据日期进行比较!
I am querying from database:
select * from database where id = 12345
and i get a couple of days where it is equal to
3/4/2010 9:16:59 AM
but if i add
and date = to_date('03/04/2010','DD/MM/YYYY')
giving me
select * from database where id = 12345
and date = to_date('03/04/2010','DD/MM/YYYY')
I comeback with completely nothing.
Any pointers?
btw, I know that there is a time on there, but I don't know how to compare just based on the day!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为当您创建日期时,您隐式地将时间设置为 0:00:00,并且由于 0:00:00 不等于 9:16:59,因此您将不会返回日期。
要告诉 Oracle 忽略时间部分,只需执行以下操作:
That's because when you are creating the date, you implicitly set the time to 0:00:00, and as 0:00:00 is not equal to 9:16:59, you'll not get the date returned.
To tell Oracle to ignore the time part, just do the following:
http://use-the-index-luke.com/sql /where-clause/obfuscation/dates
http://use-the-index-luke.com/sql/where-clause/obfuscation/dates