query execution fail while using between in javascript (labkey query api method)

LabKey Support Forum (Inactive)
query execution fail while using between in javascript (labkey query api method) Jon (LabKey DevOps)  2017-07-14 11:15
Status: Closed
 
Hi Atul,

Have you tried to redo the query with actual hard values to make sure that it works?

For example:

LABKEY.Query.executeSql({
               schemaName: 'DEMOSCHEMA',
               sql: "SELECT * FROM QUERYNAME WHERE import_date BETWEEN '2017-01-01' AND '2017-02-01'",
        success: function(data){
        alert("YES!!");
      }
});

If the above works, then I would recommend slightly modifying your code as such:

var m_fro_date=new Date(somedate);
var currentInsertDate=new Date(somedate2);

LABKEY.Query.executeSql({
               schemaName: 'DEMOSCHEMA',
               sql: "SELECT * FROM " + Importantdata + " WHERE import_date BETWEEN {ts \"+ m_fro_date + "\ }" + " and {ts \" +currentInsertDate+"\ }",
        success: function(data){
        alert("YES!!");
      }
});

Regards,

Jon