Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

86
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda