Setting a date dynamically I would like to set a date dynamically in the where clause of my query but I can't figure out how to do it. 

The query is doing a count of the number of rows with an entered on date >= 1st August year X. 

The dynamic part is how the year is calculated. 

If the query is run before 1st January the entered on date in the where clause will be currentyear/08/01. 

If the query is run from 1st January to 31st July the entered on date in the where clause will be previousyear/08/01. 

Does anyone know how this can be done?
Try using CASE expressions as you can specify qualifiers like what you're describing.
something like...

Code :

Select Count (*)
CASE when date &gt;= 1st August year X THEN enteredondate = currentyear/08/01
ELSE enteredondate= previousyear/08/01
End
from DateTable