T-SQL query with date range
Posted
by Moo
on Stack Overflow
See other posts from Stack Overflow
or by Moo
Published on 2010-05-19T13:22:27Z
Indexed on
2010/05/19
13:30 UTC
Read the original article
Hit count: 320
Hi,
I have a fairly weird 'bug' with a simple query, and I vaguely remember reading the reason for it somewhere a long time ago but would love someone to refresh my memory.
The table is a basic ID, Datetime table.
The query is:
select ID, Datetime from Table where Datetime <= '2010-03-31 23:59:59'
The problem is that the query results include results where the Datetime is '2010-04-01 00:00:00'. The next day. Which it shouldn't.
Anyone?
Cheers
Moo
© Stack Overflow or respective owner