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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATEDIFF in WHERE clause

Status
Not open for further replies.

pwills

Technical User
Sep 14, 2002
54
GB
Newbie question; what is wrong with

SELECT COMPANY FROM COMPANIES
WHERE
DATEDIFF ('m',INVOICED_ON,GETDATE()) = 1

I want to list all COMPANIES invoiced any time last month
 
Hi

Try this:

SELECT COMPANY FROM COMPANIES
WHERE
DATEDIFF (m, INVOICED_ON, GETDATE()) = 1

There is no need to have the month in quotes 'm'.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top