?SQLEXEC( 1, "Select * from MyTable where between(crtd_datetime, m.startdate, m.enddate)")You're sending text strings "m.startdate" and "m.enddate" to the server. You need
SQLEXEC( 1, "Select * from MyTable where between(crtd_datetime, ?m.startdate, ?m.enddate)")Also, you might need to use DTOT() if the field types on the back end are DateTime and yours are only dates.