May 21, 2009 at 10:30 am
I am stuck trying to format a date field to output as MMDDYY. I can get it to come out as any of the following formats but need to have MMDDYY.
yyyy/mm/dd
yyyymmdd
mm-dd-yyyy
So basically I need to format the following data 2009-05-01 13:43:15 as 050109.
Any help would be appreciated.
May 21, 2009 at 10:42 am
DECLARE @Date DATETIME
SET @Date = '2009-05-01 13:43:15'
SELECT REPLACE(CONVERT(varchar(13),@Date,10),'-','')
Check out the CONVERT function in BOL
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
May 21, 2009 at 11:11 am
Thanks, that worked. I modified it a bit for a column I need to format.
replace(convert(varchar(13),end_date,10),'-','')
May 22, 2009 at 2:12 am
Glad I could help 🙂
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply