title: How to make date function in VBScript dynamic, getting the previous date of the current date?
body: <p>I have this code here that will copy files based on the filename, by filename means getting the previous date of the current date, but my problem here is the first day of the month.</p>
  
  <pre class="lang-js prettyprint-override"><code>FSO.CopyFile "D:\Input\rep_*" &amp; Year(Now) &amp; Right("0" &amp; Month(Now), 2) &amp; Right("0" &amp; Day(Now - 1), 2) &amp; ".txt", "D:\Output\"
  </code></pre>
  
  <p>My date function is: <strong>Year(Now) &amp; Right("0" &amp; Month(Now), 2) &amp; Right("0" &amp; Day(Now - 1), 2)</strong> </p>
  
  <p>And as you can see, the <strong>Day</strong> function will get the previous day since it is minus 1. <em>Day(Now - 1)</em> </p>
  
  <p>My problem is the first day of the month. For example, today is August 1, 2016. and based on the date function above, it will find <strong>160831</strong> not <strong>160731</strong>. I am also worried since some months ends with <strong>30</strong> and <strong>31</strong>.</p>
  
  <p>Is there a way to get the previous date using VBScript dynamically? Thanks in advance.</p>