Hello everyone,
I would like to ask something regarding to take out the data from the mySQL database.
- I took the start date and stop date with the date picker node.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var date = new Date(msg.payload); // assuming msg.payload contains the epoch number
var dateString = date.toISOString().slice(0, 10);
msg.payload = null; // set the payload to null to remove it
msg.dateStart = dateString; // create a new property called "date" and assign the formatted date string
return msg; // return the modified message object
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- This is the program for the message date start and date stop. Only msg.dateStart and msg.dateStop is different
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var startDate = msg.dateStart;
var endDate = msg.dateStop;
var query = "SELECT * FROM sensor_data1 WHERE DATE(timestamp) BETWEEN '" + startDate + "' AND '" + endDate + "'";
msg.topic = query;
return msg;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This is a query about how I am taking out data from the database.
And this is the photo of the debug window.
As you can see, even though I gave the start date and stop date from the date picker node, they are separated, and if I can not get them together. I already tried that query in mySQL and it works fine.
Can someone help me regarding these issues, if I can get the data between start date and stop date, I can get the data between these values and I can use the data to make forward steps.
I am very very new to Node-Red so if there are some errors that I've done stupidly, please mention them and let me know.