Z zxf_1 Unregistered / Unconfirmed GUEST, unregistred user! 2009-05-06 #1 请教一个问题sqlserver 中一字段 varchar 内容为2007.12.10我如果按日期查怎么查
火 火焰领主打伞 Unregistered / Unconfirmed GUEST, unregistred user! 2009-05-06 #2 呵呵,和一般VARCHAR 一样,假设字段为DATESQL语句为:select * .....where date= '2007.12.10'
Z zxf_1 Unregistered / Unconfirmed GUEST, unregistred user! 2009-05-06 #5 比如我想取select * .....where date<= '2007.12.10' and date>= '2007.10.10' 这样可以吗?
F forgot2002 Unregistered / Unconfirmed GUEST, unregistred user! 2009-05-06 #7 假設日期字段為sDate,表為Table1最近一周:Select * from Table1 where cast(sDate as datetime)>=dateadd(Week,-1,getdate()) and isdate(sDate)=1昨天:Select * from Table1 whereCast(sDate as datetime)=dateadd(day,-1,getdate()) and isdate(sDate)=1如此類推....
假設日期字段為sDate,表為Table1最近一周:Select * from Table1 where cast(sDate as datetime)>=dateadd(Week,-1,getdate()) and isdate(sDate)=1昨天:Select * from Table1 whereCast(sDate as datetime)=dateadd(day,-1,getdate()) and isdate(sDate)=1如此類推....
F forgot2002 Unregistered / Unconfirmed GUEST, unregistred user! 2009-05-06 #8 如果不想要时间部分,只想要日期的话,以上的getdate()可以用cast(convert(varchar(10),getdate(),120) as datetime) 来替代