sybase中如何查询前一天的数据

表名:errorlog_201411,调用时间字段:calltime 类型datetime,如题求教如何查询前一天的数据

第1个回答  推荐于2018-03-26
  sybase中查询前一天的数据的方法:
  方法1:
  往前一天(或24小时):
StartTime between dateadd(dd,-1,getdate()) and dateadd(dd,0,getdate())
StartTime between dateadd(hh,-24,getdate()) and dateadd(hh,0,getdate())
  方法2:
  前一天24小时:
StartTime between convert(char,dateadd(dd,-1,getdate()),111) and dateadd(hh,23,convert(char,dateadd(dd,-1,getdate()),111))本回答被网友采纳
第2个回答  2014-11-13
前一天的参考值是哪天?
如果是昨天的话,
select * from errorlog_201411 where calltime>= dateadd(-1,dd,getdate() ) and calltime < getdate()
关键看参照时间。本回答被网友采纳