J
jobsxy
Unregistered / Unconfirmed
GUEST, unregistred user!
比如说我需要统计出2002-01-01至2002-06-30内所有8:00-10:00的记录,应该如何写呢?
我曾这样写
Select * from table1
where (buytime between '2002-01-01' and '2002-06-30')
and (timevalue(buytime) between '8:00:00' and '10:00:00');
搞不定,后来又换成:
Select * from table1
where (Left(buytime,10) between '2002-01-01' and '2002-06-30')
and (Right(buytime,8) between '8:00:00' and '10:00:00');
也不行,发现是日期时间的格式不是这样的,所以不能成功。我也试了convert,可能是不会
用,总是报错。
我曾这样写
Select * from table1
where (buytime between '2002-01-01' and '2002-06-30')
and (timevalue(buytime) between '8:00:00' and '10:00:00');
搞不定,后来又换成:
Select * from table1
where (Left(buytime,10) between '2002-01-01' and '2002-06-30')
and (Right(buytime,8) between '8:00:00' and '10:00:00');
也不行,发现是日期时间的格式不是这样的,所以不能成功。我也试了convert,可能是不会
用,总是报错。