title: Convert date from dd-mm-yyyy to yyyy-mm-dd in SQL Server
body: <p>I want to convert given date into the format <code>YYYY-MM-DD</code>.</p>
  <p>Given date:</p>
  <pre><code>DECLARE @Date1 VARCHAR(50) = '30-01-2015'
  </code></pre>
  <p>Now I want to convert it into the <code>2015-01-30</code>.</p>
  <h1>My try:</h1>
  <p>Try1:</p>
  <pre><code>SELECT CONVERT(VARCHAR(50),'30-01-2015',126)
  </code></pre>
  <p>Try2:</p>
  <pre><code>SELECT CONVERT(VARCHAR(50),'30-01-2015',120)
  </code></pre>
  <p>For both try the result remain same that is <code>30-01-2015</code>.</p>