[thelist] Using Wildcards and Dates in SQL Server

Chris W. Parker cparker at swatgear.com
Tue Jun 17 11:46:37 CDT 2003


Ken Kogler <mailto:ken.kogler at curf.edu> wrote:

> Why doesn't this return anything? (SQL Server 2000, IIS5, Win2K)
> 
>   SELECT * FROM curEvents WHERE eDate LIKE '6/%/2003'
> 
> I thought the % character worked as a wildcard -- am I missing
> something? 

Because there are no dates that match "6/%/2003". I've only seen %'s used like this:

SELECT id, name
	FROM products
	WHERE description
	LIKE %horse radish%

I don't think it works when it's embedded in a string literal (single quotes) as you have it.

> There's got to be a million ways to get the current month's events out
> of this table. Anyone want to suggest a better one?

You should build your sql statement dynamically using the month() function of vbscript.



Chris.


More information about the thelist mailing list