DateTime aaa=DateTime.Parse("2002-02-02");
DateTime bbb=DateTime.Parse("2002-08-08");
int x=System.DateTime.Compare(aaa,bbb);
如果x=-1 aaa<bbb
x=0 aaa=bbb
x=1 aaa>bbb
DateTime bbb=DateTime.Parse("2002-08-08");
int x=System.DateTime.Compare(aaa,bbb);
如果x=-1 aaa<bbb
x=0 aaa=bbb
x=1 aaa>bbb
select * from table where date between cast(btime as signdate) and cast(etime as signdate
用查询分析器查询看看有没错误。
我记得该没错的。
CREATE PROCEDURE upQueryTransInfoByDateTime
(
@TransDate1 datetime ,
@TransDate2 datetime
)
AS
SELECT * FROM TransInfo
where convert(char(8),OrderDateTime,112)
>=convert(char(8),@TransDate1,112)
convert(char(8),OrderDateTime,112)
<=convert(char(8),@TransDate2,112)
WHERE signdate BETWEEN CAST(Value1 AS SMALLDATETIME) AND
CAST(Value2 AS SMALLDATETIME)
"' and '" & tbto.text & "'"
就是用日期字段和字符串比较,
但是日期型的字符串必须是两位月和两位日:
"2003-07-01",不过他用的是Access,
不过我在pb中用sqlserver时用过:
select ... from table where 日期字段 between ...and....
是没问题的,and 的两边是日期型变量值.
Oracle : > < >= <= <> to_date('2001-01-02','yyyy-mm-dd')
DB2 ...
sqlstr="select * from table where date between '" & text1.text & "' and '"
& text2.text & "'"