title: How to get the date every time a day passes in nodejs?
body: <p>What I intend to do is a program that sends congratulatory emails for their birthday to several users, then the program will take today and execute a query to the database (it is an Excel file), in which it will take the date of the users and compare their date of birth with the current date, if the month and day coincide, mail will be sent. I think it can be done with a <code>setInterval()</code>, but I don't know if it affects the performance of the program. Since it will be uploaded on a windows server 2012 server of my company.</p>
  <p>My code:</p>
  <pre><code>const express = require(&quot;express&quot;);
  const app = express();
  const excel = require('./public/scripts/readExcel.js');
  const email = require('./services/email/sendEmail.js');
       
  app.post('/send-email',(req, res)=&gt;{
    setInterval(() =&gt; {
      email.sendEmail()
      .then((result) =&gt; {
          res.status(200).jsonp(req.body);;
          console.log(result)
      }).catch((err) =&gt; {
          res.status(500).jsonp(req.body);;
          console.log(err);
      });
    }, 3600000);//1 hour
      
  });
  app.listen(4000, ()=&gt;{
      console.log(&quot;Serven on -&gt; http://localhost:4000&quot;);
  })
  </code></pre>
  <p>Basically what it does is call the <code>sendEmail</code> function every hour which reads the Excel file or the database and extracts the date fields, compares with the current day, and sends the mail with Nodemailer to those who have birthdays. Also, the <code>setInterval</code> would go in the route of &quot;/send-email&quot; or how would the request be made?</p>