假如一个数据表temp中有一个datetime类型的字段tempTime,那么用其做条件来查询当天的数据时
你会发现语句
select * from temp where tempTime ='2009-08-17'
查询不到数据,除非你的数据中有‘2009-08-17 00.00.00.000’.
那么怎样才能查询到你想要的数据呀,这就需要用到convert函数,用法:
select * from temp where convert(varchar(12),tempTime,23)='2009-08-17'