SQL查询昨天记录的语句怎么写?

我数据库表有字段time 含有日期和时间的格式,如:
2008-9-12 12:4:33

我用了以下都不行:
select * from upanddown where datediff(day, convert(varchar(100),time,120),getdate())=1
select * from upanddown where time=datedadd(d,-1,getdate())
select * from upanddown where datediff(day,time,getdatetime())=1"
select * from upanddown where convert(varchar(10),time,120)=convert(d,-1,getdate())
select * from upanddown where CONVERT(varchar(100),time,23)='2008-09-25'
select * from upanddown where convert(varchar(8),time,112)='20080925'
select * from upanddown where time=date_sub(current_date,INTERVAL '1' DAY)
是Access数据库,我要查询昨天的记录,
用'2008-09-25 12:00:00' 是没办法表示昨天的,
而且数据库中9月不会显示09,直接就一个9

哈哈!我知道了!贴出答案来给大家看:
"select * from upanddown where datediff('d',time,now)=1"

第1个回答  2008-09-27
select * from upanddown where time='2008-09-25 12:00:00'
相似回答