Search code examples
datetimesybasesap-ase

Sybase How to get dash separated date yyyy-mm-dd?


I want to get date in such format yyyy-mm-dd, for example 2014-04-11. But it seems there is no way to do this in Sybase (ASE 12.5) with the convert function.

Currently, I get the date by 112 and add the - between digits. Any good way?


Solution

  • Try this:

    select str_replace( convert( varchar, col1, 111 ), '/', '-') 
    from table