简体   繁体   English

Oracle SQL日期时间查询

[英]Oracle SQL Date Time Inquiry

So I have an oracle sql table that has information that looks like below: 因此,我有一个oracle sql表,该表具有如下所示的信息:

USERID        DATETIME_STAMP               DESCR254   
=================================================================     
ZX08067       6/22/2012 4:26:03.589868 PM  Tools and Calculators
-------
-------

How would I retrieve the row shown by getting the exact DATETIME_STAMP? 如何获取确切的DATETIME_STAMP来检索显示的行? I tried the below query, but it doesn't return any rows. 我尝试了以下查询,但未返回任何行。 What's wrong with the DATETIME_STAMP part? DATETIME_STAMP部分出了什么问题?

select * from sysadm.PS_IS_STATS_URLS
where USERID = 'ZX08067'
AND DESCR254 = 'Tools and Calculators'
and DATETIME_STAMP = (to_timestamp('22/06/2012 04:26.03.589868', 'dd/mm/yyyy hh24:mi.ss.ff'))

Your database is clearly showing the time in 12-hour format with a "PM" suffix. 您的数据库清楚地以12小时格式显示时间,后缀为“ PM”。 Your query is using 24-hour time, so it's off by 12 hours. 您的查询使用的是24小时制,因此关闭时间为12小时。 The query should be: 查询应为:

select * from sysadm.PS_IS_STATS_URLS
where USERID = 'ZX08067'
AND DESCR254 = 'Tools and Calculators'
and DATETIME_STAMP = (to_timestamp('22/06/2012 16:26.03.589868', 'dd/mm/yyyy hh24:mi.ss.ff'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM