sql server - SQL "between" not inclusive -
i have query this:
select * cases created_at between '2013-05-01' , '2013-05-01'
but gives no results though there data on 1st.
created_at
looks 2013-05-01 22:25:19
, suspect has time? how resolved?
it works fine if larger date ranges, should (inclusive) work single date too.
it is inclusive. comparing datetimes dates. second date interpreted midnight when day starts.
one way fix is:
select * cases cast(created_at date) between '2013-05-01' , '2013-05-01'
another way fix explicit binary comparisons
select * cases created_at >= '2013-05-01' , created_at < '2013-05-02'
aaron bertrand has long blog entry on dates (here), discusses , other date issues.
Comments
Post a Comment