August 4, 2007 at 2:08 pm
how do I display a date as "Tuesday, July 31, 2007" and where do I find this on BOL? I can't seem to find anything under format or date.
Thanks again!
August 4, 2007 at 2:22 pm
and display just the time part of a datetime: "4:15pm" ?
August 4, 2007 at 2:32 pm
Heh... the reason why you didn't find it in Books Online is because formatting dates for a GUI in SQL is a really bad idea for about a thousand reasons, not the least of which is what format will be shown in another country if you sell your GUI overseas?
That, not-with-standing, all the parts (operative word is "parts" ) of what you want are actually in Books Online... you just need to find them all and put them together... like this...
SELECT DATENAME(dw,GETDATE()) + ', '
+ DATENAME(mm,GETDATE()) + ' '
+ DATENAME(dd,GETDATE()) + ', '
+ DATENAME(yy,GETDATE()) AS LongDate,
RIGHT(CONVERT(VARCHAR(26),GETDATE(),100),7) AS TimeOnly
--Jeff Moden
Change is inevitable... Change for the better is not.
August 4, 2007 at 3:35 pm
Thanks, Jeff. You know you're talking to a rookie. Or at least not a real SQL person. I will format on the frontend as you suggest.
August 4, 2007 at 5:26 pm
It's ok... that's why all the smiley faces... you're doing the right thing... when you have a front end involved, let it do the date formatting according to local settings.
And, thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 5, 2007 at 8:17 am
August 5, 2007 at 10:14 am
That's why you shouldn't format in the backend...
--Jeff Moden
Change is inevitable... Change for the better is not.
August 6, 2007 at 4:54 pm
Read the post, Joe... he's a rookie and he said he'd take the advice I gave him to format in the front end
--Jeff Moden
Change is inevitable... Change for the better is not.
August 6, 2007 at 5:33 pm
Heh... and you're good at it, too Good "seeing" you again.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply