sql语句 以时间为条件检索的语句问题

[复制链接]
查看11 | 回复3 | 2008-11-5 18:13:17 | 显示全部楼层 |阅读模式
使用的PL/SQL DEVELOPER 检索语句如下:
select * from prescript_sum where cashtime < to_date('2008-04-11','yyyy-mm-dd'); ----------执行成功
select * from prescript_sum where cashtime < to_date('2008-04-11 00:00:00','yyyy-mm-dd hh:mm:ss');---------- 执行失败 提示错误是格式代码出现两次
我想要将检索实践精确到秒 那么这条语句应该如何修改 THS!

回复

使用道具 举报

千问 | 2008-11-5 18:13:17 | 显示全部楼层
改成下面的就可以了。 select * from prescript_sum where cashtime < to_date('2008-04-11 00:00:00','yyyy-mm-dd hh24:mi:ss'); 原因:SQL中不区分大小写,且格式里不可出现相同的两个 mm,MM和mm被认为是相同的格式代码,所以Oracle的SQL采用了mi代替分钟...
回复

使用道具 举报

千问 | 2008-11-5 18:13:17 | 显示全部楼层
select * from prescript_sum where cashtime < to_date('2008-04-11 00:00:00','yyyy-mm-dd hh:mi:ss');yyyy-mm-dd 年-月-日hh:mi:ss 时:分:秒mm与mi区别是:月 秒...
回复

使用道具 举报

千问 | 2008-11-5 18:13:17 | 显示全部楼层
select * from prescript_sum where cashtime < to_date('2008-04-11 00:00:00','yyyy-mm-dd hh:MM:ss'); 提示错误是因为 你月份 和分钟那里用的是同样的“格式代码”时间分钟那里 应该是大写M 小写是月 若错了 那你就反过来试试(月MM 分mm)~~~ ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行