December 12, 2001 at 12:48 pm
Using SQL 2000, trying to get output of date to be in MM DD, YYYY format. Can't seem to find it anywhere. Any help is greatly appreciated.
December 12, 2001 at 1:14 pm
December 12, 2001 at 1:20 pm
I dont see a convert style that would do it, probably the closest is 101 - which would return mm/dd/yyyy. Seems like there should be something better, but this should work:
declare @Temp varchar(20)
set @Temp=replace(convert(varchar(20), getdate(),101),'/', ' ')
set @temp=left(@temp,len(@temp)-5) + ', ' + right(@Temp,4)
print @temp
If you using SQL2K I'd create it as a function.
Andy
December 13, 2001 at 10:41 am
I like it. You would happen to know how to start me off with a CASE structure to evaluate the month?
If you could start me off with something that evaluated 12 as December, I could do the rest. Been working on it all morning, but just getting errors. Thanks for the help.
December 13, 2001 at 12:07 pm
select datename(month, getdate()) will get you the name of the month. If you need to use case it could look like
case
when datepart(month, getdate()) = '01' then 'January'
when datepart(month, getdate()) = '02' then 'February'
end
You can fill in the remaining month pieces.
David
David
@SQLTentmaker“He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot
December 13, 2001 at 3:36 pm
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply