" The method you mentioned is a query by today’s date (only)"
You need to read up on how Unix/JS does date and time.
Any date variable by definition has time included (whether you specify it or not) and at the core represents milliseconds since 01/01/1970. You can then take this moment in time and display it in whatever form you need.
Once you understand that, you’ll understand what this simple code does.
You set the boundaries as needed (moments in time), then make your queries accordingly.
I’m assuming you are looking back 12 hours and 24 hours and you want just a count of orders in these time frames (last 12 hours, between 12 and 24, more than 24 hours) based on their status (open, closed).
Use the code above to establish the 12 and 24 hour boundaries.
Then use between queries with a simple count:
import wixData from 'wix-data';
// ...
// for all orders that have been placed in the last 12 hours:
wixData.query("data937")
.between("orderdate", dateNow, dateMinusTwelveHours)
.count()
.then( (num) => {
let numberOfItems = num;
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
$w("#textcount").text = num; // display query total count
A query for all orders that have been placed in the last 12 hours and are still “open”
import wixData from 'wix-data';
// ...
// for all orders that have been placed in the last 12 hours and are still "open"
wixData.query("data937")
.between("orderdate", dateNow, dateMinusTwelveHours)
.eq("status", "open") // or whatever status you need
.count()
.then( (num) => {
let numberOfItems = num;
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
$w("#textcount").text = num; // display query total count
A query for all orders that have been placed between the last 12 hours to 24 hours and are “closed”
import wixData from 'wix-data';
// ...
// for all orders that have been placed between the last 12 hours to 24 hours and are "closed"
wixData.query("data937")
.between("orderdate", dateMinusTwelveHours, dateMinusTwentyFourHours)
.eq("status", "closed") // or whatever status you need
.count()
.then( (num) => {
let numberOfItems = num;
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
$w("#textcount").text = num; // display query total count
I can’t write your code for you, but these examples should help you get started on your quest.