Is there other way to count data base on the date created? I have more than 10,000 data, I wish to count data per day. I have this code:
const date = $w("#datePicker1").value;
const options = {
year: "numeric",
month: "short",
day: "numeric"
};
let newDate = date.toLocaleDateString("en-US", options);
wixData.query("newEnrollees")
.eq("status", "PENDING")
.eq("_createdDate", newDate)
.count()
.then( (num) => {
$w("#text131").text = num.toString();
});
but when i try to query _createdDate it cant. Is there a way to do this? Thank you. I can get the data using wix dashboard but i want to display it on my website.
Hi Jefferson,
To capture all of the date/times for a given date, requires that you account for the earliest and latest possible time during that particular date. It takes a little Javascript manipulation to obtain a couple dateTime variables that can capture any record created during that date.
const date = $w("#datePicker1").value;
let yearValue = date.getFullYear();
let monthValue = date.getMonth();
let dayValue = date.getDate();
let dateValue1 = new Date(yearValue, monthValue, dayValue, 0, 0, 0);
let dateValue2 = new Date(yearValue, monthValue, dayValue, 23, 59, 59);
wixData.query("newEnrollees")
.eq("status", "PENDING")
.between("_createdDate", dateValue1,dateValue2)
.count()
.then( (num) => {
$w("#text131").text = num.toString();
});