Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda