Last day of previous month

Hi!
I am working on a query I need to run monthly. This query includes a “date” field which I need to fill in with the LAST day of thePREVIOUS month of this year. I am trying to do this by:
SELECT DATE_SUB(LAST_DAY(now()), INTERVAL 1 MONTH)
But it tells me that there is a syntax error(missing operator) in query expression. I have always worked with MySQL, so I’m not sure that the syntax is right. It could also be that I am working with the TOAD version for Data Analyst, although just with the editor part.
I would very much appreciate any ideas you cane give me.
And thanks in advance for you time!

Hi Teleki
I think you’ll be better off posting your query in an actual T-SQL forum, these forums relate to the use, configuration etc of Toad for SQL Server.

Thanks in advance

Karl

There is also a forum for Toad for Data Analysts, here’s the link: http://tda.inside.quest.com/forumindex.jspa?categoryID=144

Teleki,

I notice this is not T-SQL developer’s forum.

Anyway it seems to me that your query is something unsupported for MS SQL Server. I would recommend you to use something similar to this:
SELECT DATEADD(s, -1, DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0)) AS LastDayOfPrevMonth

you may also look into online book:
http://msdn.microsoft.com/en-us/library/ms186724.aspx

or Google: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=get+last+day+of+prev+month

Thank you Valentine!
And I’m sorry about posting it in the wrong place! :S