Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lbunch
Starting Member
9 Posts |
Posted - 2007-03-19 : 10:23:02
|
| I am using BETWEEN '02/01/2007' AND '2/01/2006' in the criteria of a VIEW and have tried <= '02/01/2007' AND >='2/01/2006' but both are not filtering the dates correctly. Is there another way? What am I missing? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-19 : 10:27:42
|
Are the date columns in the underlying tables stored as VARCHAR?If so, you have no other options than thisSELECT *FROM ViewWHERE CAST(DateCol AS DATETIME) BETWEEN CAST('20060201' AS DATETIME) AND CAST('20070201' AS DATETIME)Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-19 : 10:28:35
|
1. for BETWEEN, the 1st date should be the smaller date and the 2nd larger2. use universal format YYYYMMDD and not ambiguous MM/DD/YYYY or DD/MM/YYYY. These are language dependentBETWEEN '20060102' AND '20070102' or >= '20060102'AND <= '20070102' KH |
 |
|
|
lbunch
Starting Member
9 Posts |
Posted - 2007-03-19 : 11:58:23
|
Thank you - I used Peter's suggestion..... |
 |
|
|
|
|
|