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

135
Views
¿Cómo seleccionar un registro en la base de datos usando BETWEEN en sql?

¿Cómo seleccionar un registro en la base de datos usando BETWEEN en sql? lo que quiero aquí es seleccionar el registro dentro de startDate y endDate. si el registro existe dentro del rango de fecha de inicio y fecha de finalización, devolverá verdadero y, si no, devolverá falso

//forma

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

// codigo actual

 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; }

registro de la base de datos

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

SELECCIONE column_name(s) FROM table_name WHERE column_name ENTRE startDate Y endDate;

Básicamente: selecciona los nombres de columna que desea de la tabla. Donde la columna que contiene su fecha está entre startDate y endDate.

about 4 years ago · Juan Pablo Isaza Report

0

puede crear sp para esta operación o usar un comando sql como este

 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 Report

0

Por ejemplo, la consulta de abajo obtiene datos entre el 1 de marzo y el 30 de marzo de 2022 usando Entre.

SELECCIONE * FROM nombre_tabla DONDE nombre_columna ENTRE fecha de inicio ENTRE '2022-03-01 00:00:00' Y '2022-03-31 23:59:59';

Si su tabla tiene datos que satisfacen esta condición, habrá algunas filas en la matriz; de lo contrario, estará vacía.

Entonces, en base a eso, puede establecer su variable como verdadera y falsa.

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!