我的数据库里存的数据有分 秒 可我在查询的时候 时间段不带分秒 这样查询会有问题吗啊
select * from GPSHISTY whereDATETIME between date'2008-4-10'and date'2008-4-19';
执行这句话的时候报错:文字与格式字符串不匹配
select * from GPSHISTY whereDATETIME between date'2008-4-10'and date'2008-4-19';
执行这句话的时候报错:文字与格式字符串不匹配
这样
select * from GPSHISTY where
DATETIME between to_date('2008-4-10','yyyy-mm-dd')
and to_date('2008-4-19','yyyy-mm-dd');
------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
数据库里有分和秒的话,就这样试试:select * from GPSHISTY where
DATETIME between to_date('2008-4-10 00:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2008-4-19 00:00:00','yyyy-mm-dd hh24:mi:ss');
日期一般就用to_date(str,format)格式转换
像'yyyy-mm-dd'这样的可以直接用date'xxxx'简化, 楼主的写法没有什么问题, 估计是字段类型不匹配..------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
DATETIME between to_date('2009-12-3','yyyy-mm-dd hh24:mi:ss')
and to_date('2009-12-3','yyyy-mm-dd hh24:mi:ss'); 这样的语句为什么查不出来呢?
to_char(DATETIME,'YYYYMMDD') between '20080410' and '20080419';
这句语法有错。
to_date('2009-12-3','yyyy-mm-dd hh24:mi:ss')
to_date 函数中 2个参数类型不匹配。 ------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
DATETIME between to_date('2009-12-3 00:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2009-12-3 00:00:00','yyyy-mm-dd hh24:mi:ss');
你这样查就可以
这个会报错,不会吧,
select to_date('2008-02-02','yyyy-mm-dd hh24:mi:ss') from dual
DATETIME between to_date('2009-12-3 00:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2009-12-3 224:00:00','yyyy-mm-dd hh24:mi:ss');
trunc(to_date(DATETIME,'yyyy-mm-dd hh24:mi:ss'))=''2009-12-3'