3> CREATE FUNCTION MyDateFormat
4> (@indate datetime,
5> @Separator char(1)='-')
6> RETURNS nchar(20)
7> AS
8> BEGIN
9> RETURN
10> CONVERT(nvarchar(20), DATEPART(dd, @indate))
11> + @Separator
12> + CONVERT(nvarchar(20), DATEPART(mm, @indate))
13> + @Separator
14> + CONVERT(nvarchar(20), DATEPART(yy, @indate))
15> END
16> GO
1>
2> SELECT dbo.MyDateFormat(GETDATE(), '*')
3> GO
--------------------
17*8*2008
1>
2>
3> drop FUNCTION MyDateFormat;
4> GO