SQL statement issue

Folks,

The following SQL statement is not working and I am lost to see what is the issue. The statement works when in a VB script but not when I try and run it from notes lotus script ?

trans,whscode,dteLastsunday and dtelastmonday are variables with values from the document

strSQL = " SELECT last(ITHL11.TTDTE) as lastdtm, ITHL11.TREF, ITHL11.THLIN, ECLL02.LRDTE, ECLL02.LSDTE "

strSQl = StrSQL + "FROM BPCS.ITHL11 inner join ECLL02 ON (ITHL11.THLIN= ECLL02.LLINE AND ITHL11.TREF =ECLL02.LORD ) "

strSQl = StrSQL + " WHERE ITHL11.TWHS='" + whscode +"' AND ITHL11.TTYPE='" + trans + "' AND ITHL11.TTDTE>=" + dtelastMonday  + " And  "

strSQl = StrSQL +" ITHL11.TTDTE<=" & dteLastSunday & " and ECLL02.lqord<= ECLL02.lqshp  " 

strSQl = StrSQL +" GROUP BY  ITHL11.TREF, ITHL11.THLIN, ECLL02.LRDTE, ECLL02.LSDTE"

any help is appreciated.

Subject: SQL statement issue

you can use like this

x = uid.FieldGetText ("fieldname)

qry.SQL =“select * from LEAVE where EMP_CODE= ('”& x &"') "

res.Execute

for more call on ajitnarayan123@gmail.com