Friday, February 24, 2012

DateRange Query give wrong results

I am running some query with the following where clause

where DateCreated BETWEEN '06/01/2004' AND '06/30/2004'

It gives the records where DateCreated is of 2004-07-01 21:48:02.377

the default language on the server is British English.

Could anybody please tell me the reason why records from july are also comingBecause '06/30/2004' isn't a valid British date (no calendar has 30 months), I would guess that SQL Server assumes you want to compare string values. How 2004-07-01 got included is beyond me, but if you post the code that is causing the problem I might be able to offer more ideas.

-PatP

No comments:

Post a Comment