title: How to Convert to Datetime YYYY-MM-DD HH:mi:ss
body: <p>I have a field where I need to populate <code>GETDATE()</code> with <code>YYYY-MM-DD HH-MI-SS</code> format.</p>
  
  <p>Can anyone help me how to write the query in PostgreSQL?</p>
  
  <p>I tried this in SQL Server and it worked. Not sure how to write in PostgreSQL.</p>
  
  <pre><code>SELECT
      SUBSTRING(CONVERT(VARCHAR(23),GETDATE(),112),1,4) + '-' +
      SUBSTRING(CONVERT(VARCHAR(23),getdate(),112),5,2) + '-' +
      SUBSTRING(CONVERT(VARCHAR(23),getdate(),112),7,2) + ' ' +
      CONVERT(VARCHAR(8), GETDATE(), 108)
  </code></pre>
  
  <p>Your help is appreciated.
  Thank You 
  Swathi.</p>