odd happenings

G

Guest

I am using this query:
SELECT login.first_name, login.last_name, MAX(contedu.date)
FROM login INNER JOIN contedu ON login.ID = contedu.cont_eduID GROUP BY login.last_name, login.first_name HAVING
MAX(contedu.date) <= DATEADD("yyyy",-1,NOW())
It works fine when I test it in DreamweaverW but when I upload it to the server and look at the page I get this error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/backoffice/whats_due_education.asp, line 72

contedu.Source = "SELECT login.first_name, login.last_name, MAX(contedu.date) FROM login INNER JOIN contedu ON login.ID =
contedu.cont_eduID HAVING MAX(contedu.date) <= DATEADD("yyyy",-1,NOW()) GROUP BY login.last_name, login.first_name"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^does
anyone know what the heck i'm doing wrongthanks!
 
J

Jeff Boyce

From the error message "... expected end of statement", the first place I
looked was ... at the end of the SQL statement. I don't see a closing
semi-colon...
 
J

John Spencer (MVP)

Have to guess on this.

Try adding an alias for Max(contedu.date) in the select clause

SELECT ..., Max(contedu.date) as LastDate
....

If that fails, then try putting in a fixed date instead of using the DateAdd
function. Perhaps that function is not being recognized on the server. Or
perhaps NOW() is not being recognized as a valid function.
 
G

Gary Walter

Hi jjrmy,

One other possibility is that you need to
wrap yyyy in single quotes.

contedu.Source = "SELECT login.first_name, login.last_name, MAX(contedu.date) FROM
login INNER JOIN contedu ON login.ID =
contedu.cont_eduID HAVING MAX(contedu.date) <= DATEADD('yyyy',-1,NOW()) GROUP BY
login.last_name, login.first_name"

Good luck,

Gary Walter

I am using this query:
SELECT login.first_name, login.last_name, MAX(contedu.date)
FROM login INNER JOIN contedu ON login.ID = contedu.cont_eduID GROUP BY
login.last_name, login.first_name HAVING
MAX(contedu.date) <= DATEADD("yyyy",-1,NOW())
It works fine when I test it in DreamweaverW but when I upload it to the server and
look at the page I get this error:
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/backoffice/whats_due_education.asp, line 72

contedu.Source = "SELECT login.first_name, login.last_name, MAX(contedu.date) FROM
login INNER JOIN contedu ON login.ID =
contedu.cont_eduID HAVING MAX(contedu.date) <= DATEADD("yyyy",-1,NOW()) GROUP BY
login.last_name, login.first_name"
 
Top