如何获取两个日期之间的值.
我想获取2010年1月2日至2010年1月4日之间的值.
例:
Value DateTime
A 2010-01-01 14:55:12
B 2010-01-02 14:55:12
C 2010-01-03 14:55:12
D 2010-01-04 14:55:12
E 2010-01-05 14:55:12
谢谢!
解决方法:
看一下
If expr is greater than or equal to
min and expr is less than or equal to
max, BETWEEN returns 1, otherwise it
returns 0.
/
For best results when using BETWEEN
with date or time values, you should
use CAST() to explicitly convert the
values to the desired data type.
Examples: If you compare a DATETIME to
two DATE values, convert the DATE
values to DATETIME values. If you use
a string constant such as ‘2001-1-1’
in a comparison to a DATE, cast the
string to a DATE.