Sometimes, you have to store the data/time value into nvarchar format so that it can be understand by other programs that easier. You need this function to convert the date/time value into nvarchar:
create function fn_to_sys_date
(
@dt as datetime
)
returns nvarchar(50)
begin
/*
9-may-12,lhw
-format the date value to human readable format.
select dbo.fn_to_sys_date(getdate())
*/
declare @result nvarchar(50)
select @result = replace(convert(nvarchar,@dt,102),
'.',
'')
+ replace(left(convert(nvarchar, @dt, 114), 8),
':',
'')
return @result
end
No comments:
Post a Comment