[thelist] Using Wildcards and Dates in SQL Server

Ken Kogler ken.kogler at curf.edu
Tue Jun 17 15:17:00 CDT 2003

Gary said:

> Glad I could help, but Jason made a further improvement which is the
> way to go if you're trying to compare the eDate field to the current
> as opposed to a fixed date.

And Jason said:

>  SELECT * FROM curEvents
>	AND DATEPART(yyyy, eDate) = DATEPART(yyyy, GETDATE())

That's closer to what I ended up doing. I already have the current month
and year stored as variables in ASP, so rather than have SQL server
figure them out, I concatenated the string like so:

  sql = "SELECT * FROM curEvents " & _
	" WHERE DATEPART(mm, eDate) = " & curMonth & _
	" AND DATEPART(yyyy, eDate) = " & curYear

So thanks for the help, guys, and I've filed this away in the code


More information about the thelist mailing list