Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Sunday, May 17, 2009

Date Between Syntax Bug from MS SQL Server 2005?

1. select TradeDate from test where TradeDate between '2009-05-13 00:00:00.000' and '2009-05-13 23:59:59.999'
result:
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
(5 row(s) affected)


2. select TradeDate from test where TradeDate between '2009-05-13 00:00:00.000' and '2009-05-13 23:59:59.998'
result:
(0 row(s) affected)


3. select TradeDate from test where TradeDate between '2009-05-13 00:00:00.000' and '2009-05-14 00:00:00.000'
result:
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
2009-05-14 00:00:00.000
(5 row(s) affected)