title: How to work with Windows Task Scheduler to get last run date using Java
body: <p>I want to send a report of Registered users on the website every week from users' table in MySQL/Oracle database. For this, I have created a Java program that fetches registered users within a week and saves it in an excel file and sends it in a mail. I'm scheduling this task with Windows Task Scheduler to run every week. I want to get the last run time of that scheduler and next run time to add in the SQL query. </p>
  
  <p>My SQL query is as below.</p>
  
  <pre><code>SELECT * FROM USERS WHERE TRUNC(USER_CREATION_DATE) BETWEEN 'FROMDATE' AND 'TODATE'; 
  </code></pre>
  
  <p><code>FROM_DATE</code> and <code>TO_DATE</code> will be the variables.</p>
  
  <p>Is there are any better approach to get <code>FROM_DATE</code> and <code>TO_DATE</code> when the scheduler runs on the first day of the week (i.e Sunday), which means I want last Sunday as <code>FROM_DATE</code> and Saturday as <code>TO_DATE</code> in Java.</p>
  
  <p>Please help me to get <code>FROM_DATE</code> and <code>TO_DATE</code> of last week.</p>