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

134
Views
sequelize nodejs return the data that are supposed to show up at the current time

I have Product Model That Have Two Columns startDate and duration

The startDate it's the datetime are products supposed to show up

And duration is the showing time per day,

This is the code I have written

const dateTimeNow = new Date() 
    const productData = await productModel.findAll({
            where: {
               startDate: { [Op.gte]: dateTimeNow }, // StartDate >= dateTimeNow
            },

what I want Is : find all products where startDate >= date.now() & startDate + duration <= date.now()

how can I do that in sequelize?

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

0

From the Sequelize doc, you can use

const Op = Sequelize.Op;

// startDate and endDate are Date objects
const where = {
    startDate: {
        [Op.between]: [startDate, endDate]
    }
};

NOTE: between is inclusive that means (startDate <= from AND from <= endDate)

Learn more on operators in the doc http://docs.sequelizejs.com/en/latest/docs/querying/#operators

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!