date1 := '2012-05-30 20:00:00';
date2 := '2012-05-30 20:59:59';从sql数据库,选择这个时间段内符合条件的记录,怎么写?
select * from table where 字段>=date1 and 字段<=date2
date2 := '2012-05-30 20:59:59';从sql数据库,选择这个时间段内符合条件的记录,怎么写?
select * from table where 字段>=date1 and 字段<=date2
SQL.Tet:='select * from table where 字段 between '+Quotedstr(date1)+' and '+Quotedstr(date2);date1与date2是日期
SQL.Tet:='select * from table where 字段 between '+Quotedstr(DateTimeToStr(date1))+' and '+Quotedstr(DateTimeToStr(date2));或用参数形式:
SQL.Tet:='select * from table where 字段 between :d1 and :d2';
Parameters.ParamByName('d1').Value:=date1;
Parameters.ParamByName('d2').Value:=date2;
select * from table Where 时间字段 Between date1 and date2
Select CONVERT(char(12),Getdate(),104)
Select CONVERT(char(12),Getdate(),112)
Select CONVERT(char(12),Getdate(),114)
Select CONVERT(char(12),Getdate(),120)