Search code examples
sqlsap-asesap-iqisql

want to convert string mm/dd/yy to date yyyy/mm/dd format in Sybase


I want to convert date which is string and like mm/dd/yy to date datatype in format yyyy/mm/dd.


Solution

  • I would double cast it, once to datetime, then back to varchar.

    select convert(varchar,convert(datetime,'12/14/2012'),101)
    

    This works on SQL Server, but I don't have a Sybase instance to test on.

    Edit: Looks like you could also use this:

    select convert(varchar,date('12/14/2012'),101)