Literal与oracle中日期持续时间中的格式字符串不匹配

时间:2015-08-21 15:15:11

标签: oracle

我正面临着问题,请帮助我,我的代码是

SELECT 'NULL' AS sender_mobile,
       ci.str_identification AS receiver_mobile,
       TO_CHAR (cc.dat_creation, 'YYYYMMDD') AS datee,
       TO_CHAR (cc.dat_creation, 'hh24:Mi:ss') AS timee
FROM   pbxhbl.agent_details ad
       INNER JOIN pbxmob.customers_identifications ci
         ON ad.id_customer = ci.id_customer
       INNER JOIN pbxmob.customers_credentials cc
         ON ci.id_customer = cc.id_customer
       INNER JOIN pbxmob.credential_types ct
         ON cc.id_credential_type = ct.id_credential_type
WHERE  cc.dat_creation BETWEEN '21-August-2015 06:00:00 PM'
                           AND '21-August-2015 06:59:59 PM';

1 个答案:

答案 0 :(得分:1)

如果您明确表示日期格式,那么您会感觉更好。下面是一个与查询相同的示例:

  where cc.DAT_CREATION
between to_date('2015-08-21 18:00:00', 'YYYY-MM-DD HH24:MI:SS')
    and to_date('2015-08-21 18:59:59', 'YYYY-MM-DD HH24:MI:SS')