September 25th, 2003, 08:28 AM
How do I change this function so that it shows dates like this 2003-05-03 and not 2003-5-3?
And I also want to add a parameter so that the user can choose if it should show :
2003-03-03 or 03-03-03
create function ShowDate(@indate datetime, @separator char(1))
convert(nvarchar(20), datepart(yyyy, @indate))
+ convert(nvarchar(20), datepart(mm, @indate))
+ convert(nvarchar(20), datepart(dd, @indate))
September 29th, 2003, 12:15 PM
this will get your date the way you want it, except it uses . instead of - as a seperator. what programming language are you using to display this data?
select convert(varchar(20),date_field,102) as 'date' from table_name
My brain cells are like a storm trooper's armor: useless
September 29th, 2003, 12:53 PM
I solved my problem by sitting up all night, but thanks for your input!