【问题标题】:oracle 'ora-01843' date format error in the sqlsql中的oracle'ora-01843'日期格式错误
【发布时间】:2020-09-05 06:28:53
【问题描述】:

我有一个表格和数据如下

id joining_date

1  11-05-2020 04:15:57

我想使用日期格式从该表中导出

我正在使用:

select * from table where joining_date=TO_date('11-05-2020 04:15:57')

但我收到ora-01843 错误

请任何人帮助..让我知道结果

【问题讨论】:

  • 你必须在 to_date 中指定字符串的格式,'DD-MM-YYYY hh24:mi:ss',除非你的会话设置在 nls_date_format 中有这个
  • 它的工作谢谢@gsalem

标签: sql oracle date oracle11g


【解决方案1】:

您可以使用时间戳常量进行比较:

where joining_date = timestamp '2020-05-11 04:15:57'

即使joining_date 存储为date 而不是timestamp,这也将起作用。 dates 精确到一秒。

【讨论】:

    【解决方案2】:

    joining_date=TO_date('11-05-2020 04:15:57')

    您缺少所需的格式掩码:

    TO_DATE ('11-05-2020 04:15:57', 'DD-MM-YYYY HH24:MI:SS')
    

    【讨论】:

      猜你喜欢
      • 2014-11-21
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多