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

137
Vistas
How to select record in the database using BETWEEN in sql?

How to select record in the database using BETWEEN in sql? what I want here is to select record within the startDate and endDate. if the record is exists within the range of startDate and endDate it will return true and if not it will return false

//form

formData = {
    "startDate": "14/04/2022 09:41 PM",
    "duration": 3600000,
    "assignedTo": "441017201|441017210",
}

// current code

var hasExistingEvent = (assignedTo, startDate, end) => {
    var assigne = assignedTo.split("|")
    var userFilters = assigne.map((user) => {
        return `Assigned_To_Ids LIKE '%${user}%'`;
    }).join(" OR ");
    return  new Promise((resolve, reject) => {
        .....,("SELECT Assigned_To_Ids, startDate FROM Event WHERE ("+ userFilters +") AND (startDate BETWEEN '" + moment(startDate).format() + "' AND '"+ moment(end).format() + "')", 100, function(data){
            return resolve(data.length ==0)
        })
    })
}

var validatedUserExistsEvent = async(formData) => {
    var {  assignedTo, startDate, duration } = formData
    var dd_startDate = moment(startDate, 'DD/MM/YYYY HH:m A').toDate()
    var end = new Date(dd_startDate);
        end = new Date(end.setTime(end.getTime() + duration));
    var hasExisting = await _data.hasExistingEvent(assignedTo, dd_startDate, end);
    return hasExisting;
}

record from database

enter image description here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN startDate AND endDate;

So basically: You select the column names that you want from the table. Where the column that contains your date is between startDate and endDate.

about 4 years ago · Juan Pablo Isaza Denunciar

0

you can create sp for this operation or use sql command like this

select case when exists (select * from Ls2 where date between @startdate and @EndDate) then 1 else 0 end
about 4 years ago · Juan Pablo Isaza Denunciar

0

For Example, Below query fetch data between March 1 to March 30 2022 using Between.

SELECT * FROM table_name WHERE column_name BETWEEN startDate BETWEEN '2022-03-01 00:00:00' AND '2022-03-31 23:59:59';

If your table has data satisfying this condition, there will be some rows in array otherwise it will be empty.

So based on that, you can set your variable as true and false.

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