你看看你的时间'9:00:00' 都是7位的字符串,现在你将他们和长度为5(varchar(5),)的字符串相比,则结果肯定是容易出问题的。 "select count(car_fee_id) from car_park_fee where car_fee_start between '" + d_start + "'and '" + d_end + "' and cast(car_fee_start as time) between '9:00:00' and '9:59:59' " 如果你的sql是2008的就换成上面这种写法,如果是2005就将varchar的长度改成8试试
"select count(car_fee_id) from car_park_fee where car_fee_start between '" + d_start +
"'and '" + d_end + "' and cast(car_fee_start as time) between '9:00:00' and '9:59:59' "
如果你的sql是2008的就换成上面这种写法,如果是2005就将varchar的长度改成8试试
convert(varchar(8),car_fee_start,108)