First a simple question: Is it allowed to provide a date range that
has an illegal date. For instance
SELECT * FROM tbl WHERE datex >= 2007-09-01 AND datex <= 2007-09-31
Now for my real question. I have a table with a column named
last_update_date that is indexed. I would like to find all records in
this table where last_update_date has a certain year and month.
The actual date which has the year and month is an in a programming
language string, so I am doing substring operations to find the proper
month and day:
SELECT
*
FROM
xfer_tbl
WHERE
AND MONTH( last_update_date ) = CONVERT(INT, SUBSTRING('$
{START_DATE}', 5, 2))
AND YEAR( last_update_date ) = CONVERT(INT, SUBSTRING('$
{START_DATE}', 1, 4))
But as you can see, this does not take advantage of the databases (MS
SQL 2000) indexing power does it? It would be better to use >= and <=
as in my first sample query, but then I run the risk of using an
illegal date.