[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

best way render date in MMDDYY format

Eric Bragas

3/21/2007 11:31:00 PM

Hi People,

What is the best way to render a date in MMDDYY format using T-SQL? I
need to include a zero in MM if the month is 1-9.

Thanks,
Eric

2 Answers

Hugo Kornelis

3/21/2007 11:40:00 PM

0

On 21 Mar 2007 16:31:22 -0700, Eric Bragas wrote:

>Hi People,
>
>What is the best way to render a date in MMDDYY format using T-SQL? I
>need to include a zero in MM if the month is 1-9.
>
>Thanks,
>Eric

Hi Eric,

It's a hideous format, prone to errors, but if you really need it this
way use:

SELECT REPLACE(CONVERT(char(8), CURRENT_TIMESTAMP, 10), '-', '');

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hug...

Eric Bragas

3/21/2007 11:44:00 PM

0

Thank you, Hugo, this is much cleaner than the mess I came up with. I
wouldn't use this format if the customer didn't require it. Thanks
for the warning, I will also keep that in mind.

-Eric