title: '7 days ago' date format issue in crontab
body: <p>I am running a cron which includes a curl whch includes values for startDate and endDate which must be in the format yyyy-mm-dd. endDate is today and startDate is 7 days ago. Overall format is:</p>
  
  <pre><code>curl -o ~/location/filename.xml "http://url.asmx/do_this?&amp;startDate=x&amp;endDate=y"
  </code></pre>
  
  <p>Using a fixed start date this works running via terminal on macosx:</p>
  
  <pre><code>&amp;startDate=2014-10-01&amp;endDate=`date +\%Y-\%m-\%d`"
  </code></pre>
  
  <p>However, remembering that startDate should be 7 days prior to the system date, both of the methods below result in an error 'The specified Date was not in correct format. Dates should be in format: YYYY-MM-DD, such as 2011-12-24'</p>
  
  <pre><code>startDate=`date -d '7 days ago' +\%Y-\%m-\%d`&amp;endDate=`date +\%Y-\%m-\%d`
  startDate=`date --date="7 days ago"  +\%Y-\%m-\%d`&amp;endDate=`date +\%Y-\%m-\%d`
  </code></pre>
  
  <p>Is this an issue with using " ' and `?</p>
  
  <p>What am I doing wrong here? BTW I am trying to keep within a one line command line rather than use a script in a file.</p>
  
  <p>EDIT: From Googling and copying and pasting many suggestions, I have found that the following on a Mac forum that works:</p>
  
  <pre><code>$(date -v-7d +%Y-%m-%d)
  </code></pre>
  
  <p>However I've not come across -v before. I'm wondering what it is, is it Mac specific and will this present problems on other servers?</p>