In SQL Server, can I do the equivalent of
to_char(date_field, 'YYYY-MM-DD:HH24') in Oracle to get
You can use the CONVERT() function and pass it one of the precanned styles. Looks like style 120 (ODBC Canonical) is the closest to what you specifiy.
Also, have a look at Pinal Dave's UDF here. It's quite a bit more flexible.
|show 1 more comment|
In SQL Server <= 2012 you can say:
In SQL Server 2012 this is much easier; you can say:
SQL fiddle: http://sqlfiddle.com/#!6/72276/5