Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
how can I make a function which will return a number of Schedule Dates that are matching with other Item_date from my database

I want to create a function where Item_date will be received from my Database and will return a number of Schedule Dates that are matching with other Item_date.

For instance, I can select 2021-05-20, and the function will return :

19th November: 2 Scheduled

18th November: 2 Scheduled

Can anyone give me an idea of how can I make it?

This is my database example:

[
    {
        "schedule_time": "2021-05-17 12:39:29",
        "slot": "L",
        "item_date": "2021-05-18"
    },
    {
        "schedule_time": "2021-05-17 12:47:53",
        "slot": "D",
        "item_date": "2021-05-18"
    },
    {
        "schedule_time": "2021-05-18 13:55:22",
        "slot": "D",
        "item_date": "2021-05-19"
    },
    {
        "schedule_time": "2021-05-19 16:09:15",
        "slot": "L",
        "item_date": "2021-05-20"
    },
    {
        "schedule_time": "2021-05-19 16:11:55",
        "slot": "L",
        "item_date": "2021-05-20"
    },...

]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you want the other dates you need to do this suppose array is the array where your database info are , and the dbItemDate the parameter passed to javascript :

let dbItemDate="2021-05-20";
let otherDayArray= array.filter(num=>num.item_date!=dbItemDate);
console.log(otherDayArray);//this is the new array of others date 
let count = otherDayArray.reduce(function(acc,num){
    
    acc[num.item_date]=(acc[num.item_date]||0)+1;
    return acc;
},[]);
console.log(count);//this should print the frequency of each date in the others date array 

and if you want the same date just replace the condition in array.filter to

let otherDayArray= array.filter(num=>num.item_date===dbItemDate);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!