Monday, January 19, 2004

Convert Date to ISO (SQL Server)

To convert a date column into ISO format (YYYY-MM-DD) using SQL, the following code can be used:

LEFT(CONVERT(char(10), DateColumn, 126), 10) AS DateFormatted

Or using '/' as the seperator:

REPLACE(LEFT(CONVERT(char(10), DateColumn, 126), 10), '-', '/') AS DateFormatted

No comments: