Hi, I have a problem in a view. I try do do a simple view with a filter on a datetime field. The filter is very simple >= 01/0/2007 and <01/01/2009. SQL Server give me back no rows in this view and this is wrong. I have tried to do it in access and if I use linked tables it still doesn't work but if I copy the table in the access database it works perfectly. One of you has some ideas?? Thanks Francesco
Don't use BETWEEN, there are well documented issues with fringe cases.
It's most likely to do with how you are specifying the dats in your WHERE clause. YYYYMMDD is the format guaranteed to work regardless of regional settings. You also need to wrap you date with single quotes, otherwise 01/01/2009 is evaluated as anumeric operation i.e. 1 divided by 1 divided by 2009
Try this:
WHERE column >= '20070101' AND column < '20090101'
Adam Tappis. (MCSD VB6 & .NET, MCDBA SQL 2000)
Edited byAdam TappisWednesday, November 04, 2009 11:46 AM