日期:2014-05-17  浏览次数:20993 次

请教一个简单的sql,关于时间的
假设有这么一个表,表名为a,只有两个字段,
id,number(3)
tt,date
现在我要使用sql语句插入记录,语句如下:
insert   into   a(id,tt)   values(1,to_date( '2007-05-20   13:20:34 ', 'yyyy-mm-dd   hh;mi:ss '));

执行时语句报错,hour只能在0~12之间,然后将sql语句修改为
insert   into   a(id,tt)   values(1,to_date( '2007-05-20   13:20:34   PM ', 'yyyy-mm-dd   hh;mi:ss   AM '));
执行时仍然报错,请教这是什么问题,该如何解决,多谢



------解决方案--------------------
你数据库的时间格式不是24小时制的
------解决方案--------------------
insert into a(id,tt) values(1,to_date( '2007-05-20 13:20:34 ', 'yyyy-mm-dd hh24;mi:ss '));
------解决方案--------------------
insert into a(id,tt) values(1,to_date( '2007-05-20 13:20:34 ', 'yyyy-mm-dd hh24;mi:ss '));
lalakid(梦想总是那么美好……)的解答不对
------解决方案--------------------
你的语句:
insert into a(id,tt) values(1,to_date( '2007-05-20 13:20:34 ', 'yyyy-mm-dd hh;mi:ss '))。

怎么在 'yyyy-mm-dd hh;mi:ss '中的hh后面是分号?应该也是冒号,yyyy-mm-dd hh:mi:ss
------解决方案--------------------
Hero__008(北斗魁星) 的是对的.

> select to_date( '2007-05-20 13:20:34 ', 'yyyy-mm-dd hh24;mi:ss ')
2 from dual;

TO_DATE( '2007-05-20
-------------------
2007-05-20 13:20:34