数据库是以前别人设计的 有一个字段dt是表示时间,但是设计时的数据类型是字符型现在我要把dt的时间小于当前时间的数据提取出来,该怎么写?比如;dt里为2010-8-11 今天是2010-12-3 那么就得把这条信息提取出来 SQL语句该怎么写?
string qstr="select * from table where dt<='"+datetime.now.data()+"'"; ?急,帮帮忙!!!c#.net
string qstr="select * from table where dt<='"+datetime.now.data()+"'"; ?急,帮帮忙!!!c#.net
string qstr="select * from table where dt<=getdate()";
select convert(datetime,dt,120) as dtTime from table where datediff(d,convert(datetime,dt,120),getdate)>0
#2. dt字段转换成datetime类型,再对比
SELECT * FROM table_name WHERE CAST(dt AS DATETIME) < GETDATE()
string qstr="select * from table where cast(dt as datetime) < getdate() "
select * from tb where convert (datetime,col)<getdate()