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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -