为什么没有得到结果?sql查询简单正确,可在mysql 中使用
const getDateBw = (InvoiceDate1, InvoiceDate2, err, req, res) => {
let startDate = new Date(InvoiceDate1);
let endDate = new Date(InvoiceDate2);
let formattedDate1 = JSON.stringify(dateFormat(startDate, "yyyy-mm-dd"));
let formattedDate2 = JSON.stringify(dateFormat(endDate, "yyyy-mm-dd"));
console.log(formattedDate1);
db.query(
"SELECT * FROM dashboard WHERE Invoice_Date BETWEEN " +
formattedDate1 +
" " +
"AND " +
formattedDate2
).then(function (myTableRows) {
res.json({
myTableRows,
});
});
};
getDateBw("2009-05-21", "2021-01-01");
{"level":50,
"time":1598543997608,
"pid":10772,
"hostname":"Ghadi-Mdallal",
"stack":"TypeError: Cannot read property 'json' of undefinedn at C:\Users\LENOVO\Desktop\Dashboard-V1\empServer\handlers\user.controllers\user.controllers.js:29:9n at processTicksAndRejections (internal/process/task_queues.js:97:5)",
"type":"Error",
"msg":"Cannot read property 'json' of undefined"
}
您没有通过"res";在getDateBw("2009-05-21"、"2021-01-01"(中;
res.json将如何在内部工作?它将给出";无法读取未定义的"的属性"json";错误