Sybase: How to get the current date in mm/dd/yyyy format?

swateek picture swateek · Sep 28, 2013 · Viewed 25.3k times · Source

I want to insert the mm/dd/yyyy format into a table and after that compare it with the current date when fetching results from the table to display.

The getdate() function returns the complete timestamp and am unable to extract the date in my desired format.

Answer

Rahul Tripathi picture Rahul Tripathi · Sep 28, 2013

You are looking for this SQL to make the conversion:

select convert(varchar, date_column, 101) from the_table

The important part in part in this case is 101 which is specification of mm/dd/yyyy format as per documentation. If you have Sybase ASE 15.7 use this, if you have SAP ASE 16.0 (released 2014) use this (has more options).