Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql : use current year as criteria

Status
Not open for further replies.
Joined
Oct 6, 2002
Messages
60
Location
US
Hello experts,

I am having a terrible time getting this where statement to work. All I want to say is: SELECT * FROM mytable WHERE mytable.date > 02/01/(of last year). Of course the (of last year) part is the part of the syntax that I cannot get to work. I know I can use the DatePart function but I cannot get past the syntax errors. Thanks in advance for any help you can provide.

Ryan
 
Hi

How about

"SELECT * FROM mytable WHERE mytable.date > #" & Format("02/01/" & Str(Year(Date())-1)."mm/dd/yy") & "#;"


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi boomer1974,

Or ...

Code:
"SELECT * FROM mytable WHERE mytable.date > DateSerial(Year(Date())-1,2,1);"

(where the 2 is the month and the 1 the day - I don't know what format date you're using in your example).

Enjoy,
Tony
 
Thanks Guys, that worked perfectly

boomer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top