-3

I ran this following query and somehow I feel the results are wrong.

SQL> select to_char(starttime,'dd-mm-YYYY hh24:mi:ss') 
from report 
where dateofmonth between 
    to_timestamp_tz('22-Apr-2013 12:00:00','dd-mm-YYYY hh24:mi:ss') 
    and to_timestamp_tz ('23-Apr-2013 14:00:00','dd-mm-YYYY hh24:mi:ss');

TO_CHAR(STARTTIME,
--------------------
23-04-2013 22:43:59
23-04-2013 13:43:37

SQL> select to_timestamp_tz(starttime,'dd-mm-YYYY hh24:mi:ss') 
from report 
where dateofmonth between 
    to_timestamp_tz('22-Apr-2013 12:00:00','dd-mm-YYYY hh24:mi:ss') 
    and to_timestamp_tz ('23-Apr-2013 14:00:00','dd-mm-YYYY hh24:mi:ss');

TO_TIMESTAMP_TZ(STARTTIME,'DD-MM-YYYYHH24:MI:SS')
-------------------------------------------------
23-APR-13 10.43.59 PM -07:00
23-APR-13 01.43.37 PM -07:00

I am not sure why the 10 PM time is coming up in the result.

4

1 回答 1

0

曼吉特,

您正在选择 starttime 列,但 where 子句具有 dateofmonth 列。在查询中同时选择 starttime 和 dateofmonth 并检查它是否给出了正确的结果。

于 2013-04-24T05:51:58.140 回答