extracting the ISO date from a datetime object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I spent one hour looking for a way to extract a string in the format
yyyy-mm-dd from a date time object.
At the end I give up and I defined a custom function:

CREATE FUNCTION isodate10(@date datetime)
RETURNS CHAR(10) AS BEGIN
RETURN cast(year(@date) as char(4)) + '-' +
cast(month(@date) as char(2)) + '-' +
cast(day(@date) as char(2))
END

What's the name of this function in SQL Server 2005? Is there a
simpler way of doing this?
Thanks,

M.S.
.



Relevant Pages