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

143
Views
repeat events on certain dates node.js

I have a function in which stores the current date, and time (timestamp) in mysql db.

formatted like so:

'2022-01-28 13:00:00.000000'

The way this gets inserted into my table is like so:

    var insertNewEvent = "INSERT INTO SCHEDULE (DATE,LOCATION,ASSIGNED_TRAINER,CLIENT_USERNAME,ENDDATE, ID, EVENT_NAME, SESSION_STATUS) VALUES('" + eventDetails.eventDate + " " + eventDetails.eventStartTime + "', '" + eventDetails.eventLocation + "', '" + eventDetails.trainerUserName + "', '" + eventDetails.selectedClient + "', '" + eventDetails.eventDate + " " + eventDetails.eventEndTime + "', '" + uniqueID + "', '" + eventDetails.nameOfEvent + "', '" + session_status + "')"

and yes, I am changing this query as I know it is unsafe and not right.

but now what I want is for example, I want to say insert the same event (all same event details), but have it repeat on the day i inserted it for, and then every let's say monday, wednesday, friday after that. I am a little but stumped on how to go about this, I was hoping someone could guide me. thanks.

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

0

try creating a middleware to handle it, for example:

var checkDate= Date.UTC(new Date().getFullYear(), new Date().getMonth(),
              (new Date().getDate() + 1));
const myMiddleware= async(req, res, next) =>{
    if(Date.now()>= checkDate){
        checkDate= Date.UTC(new Date().getFullYear(), new Date().getMonth(),
                   (new Date().getDate() + 1));
        // your code here
        
    }
    next();
}

then use it

app.use(myMiddleware);
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!