title: SQL query convert today date into yyyymmdd
body: <p>We have a SQL Server 2000 database for our business. Now I'm trying to make an easy to use and readable output for our staff. The SQL query I made works fine, but as said I want to make it easy to use. So that our employee only has to press an update button and he or she receives the actual numbers.</p>
  
  <p>The database uses on every record an <code>UPD_DAT</code> column containing to actual date that record is made. But in a <code>YYYYMMDD</code> format. So for today it is <code>20170512</code>. So far so good. Now I want to use today as query. So I googled and tried something with <code>Datepart</code> and <code>getdate</code>. But somehow it won't work. </p>
  
  <p>So I get something like that:</p>
  
  <pre><code>SELECT data 
  FROM table 
  WHERE UPD_DAT = (DATEPART("YYYY", (GETDATE())) * 100 +  
                   DATEPART("MM", MONTH(GETDATE()))) * 100 +  
                   DATEPART("DD", (GETDATE()))
  </code></pre>
  
  <p>I started in January whit this query and thought that it's working. Today I continued whit it and noticed some problems. The result I get is in January not in may, I get <code>20170112</code> instead of <code>20170512</code>. </p>
  
  <p>As mentioned it is SQL Server 2000. </p>