sql - 如何在oracle sql中获取时间字符串到Time

标签 sql oracle datetime time

我在 oracle VARCHAR2 列中以字符串形式插入时间。但是当我尝试以时间形式检索它时,它并没有给我正确的时间,它只是给了我一个我尚未保存的日期。

INSERT INTO table1
    (timestr) Select substr(numtodsinterval(MAX(date1)-MIN(date2),'day'),
12,8)  from table2 where ....; // stored timestr column value: 00:00:00

检索...

select TO_DATE(timestr,'hh24:mi:ss') from table1; 

...仅给出10/01/2015

最佳答案

您应该使用 to_char 来查看时间

 select to_char(timestr,'hh24:mi:ss') from table1; 

关于sql - 如何在oracle sql中获取时间字符串到Time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33141260/

相关文章:

sql - 将值 "Good"和 "Bad"转换为 bool 值以计算百分比(即,从所有记录中,80% 为 "Good") - 使用 SQL

sql - 使用条件计算postgresql中的百分比

sql - 选择最近但不大于行

oracle - 如何查看oracle云上创建的表

sql - 如何创建一个 View 表来显示同一员工的当前记录数和总数?甲骨文数据库

从开始日期到结束日期的 PHP 空闲时间 block

mysql - 如何在sql中查询多个多对多关系

如果主键存在于不同的表中,php mysql 尝试使用空仅在表中添加新记录

c# - 如何让 Web Api 查询字符串参数绑定(bind)保持 UTC 日期?

php - 如何在 php mysql 中将 varchar 转换为日期?