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 the PREVIOUS month of this year. I am trying to do this by:SELECT ([31/] + MONTH(DATEADD(mm,-1,DATE())) + '[/]' + YEAR(DATE())) as MyTimeBut it tells me that "there are too few parameters".Also, this is not a very good solution since not every month has 31 days.I would very much appreciate any ideas you cane give me.And thanks in advance for you time!
If I understand your question correctly - you want the last day of the previous month? MySQL has a LAST_DAY function already.SELECT DATE_SUB(LAST_DAY(now()), INTERVAL 1 MONTH)Hope that helps
Thank you very much!!I think that's exactly what I need. I'll try the trick today and let you know. Maybe it was a very dumb question, but I'm a newby so... sorry for wasting your time! :)
Hi Wetty,So I tried the statement just as you posted it but it gives me an error saying the there is a syntax error(missing operator) in query expression. Is the syntax for MySQL the same as for TOAD for Data Analyst? Thank you
Shouldn't be any difference. What version of MySQL are you using?
I'm using TOAD for Data Analyst 22.214.171.1240. I realised that some of the statements in SQL are different, although not really sure why! :S
Oh! Sorry!I belive is Microsoft SQL Server 2005 - 9.00.4035.Is this what you are asking for?
You are right. Sorry about that and thanks for your time! :)