title: Is there a portable conversion of a datetime column to string using SQL
body: <p>I have a column defined as a datetime in sybase and have converted it to a string using</p>
  
  <pre><code>ISNULL(CAST(CAST(most_recent_trades.asof_date AS DATE) AS VARCHAR(20))
  </code></pre>
  
  <p>It turns out that the representation of this as a string in sybase differs from my unit test db which is H2.</p>
  
  <pre><code>In sybase
  Sep  1 2016
  
  In H2
  2016-09-01
  </code></pre>
  
  <p>The column is defined as datetime in H2 as well.</p>
  
  <p>Is there a way to convert the datetime column to a string that is the same string representation in both Sybase and H2 (I don't need the time portion of this if that helps any)?</p>
  
  <p>EDIT :
  I don't think there is any way to do this in a portable way with one function, so what I decided to do was use the YEAR, MONTH and DAY functions (they are all available in Sybase and H2), extract the parts and concatenate them to make a date that will look the same when represented as a string in both Sybase and H2. This works for me at this point.</p>