Format date in SQL

I have a datetime field (MS SQL 2008) and I would like to format it like this: 8/22/2014 10:25

I am trying to format it like: mm/dd/yyyy hh:ss (or mm-dd-yyyy hh:ss would be fine too.)

I tried using "convert" but I am not having any luck.

Could someone assist?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
You might need 2 converts to get both parts. Couldn't see an obvious way.

declare @dt datetime
select @dt = GETDATE()

select CONVERT(nvarchar(8), @dt, 101) + ' ' + CONVERT(nvarchar(5), @dt, 108)

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
SET @myDateTime = '8/22/2014 10:25'

-- Convert string
SELECT @myDateTime, CONVERT(VARCHAR, @myDateTime, 101) + ' ' + CONVERT(VARCHAR, @myDateTime, 114)

Open in new window

Éric MoreauSenior .Net ConsultantCommented:
damn, 30 seconds to late!
Shaun KlineLead Software EngineerCommented:
If you want that format, you will need to use two separate CONVERT statements: (assuming your time format should have included minutes)


Open in new window

In this format, hours uses a 24 hour clock.
mm/dd/yyyy hh:ss

why would you not want minutes?

I'm intrigued

btw:  if you have SQL 2012 or later:


SELECT FORMAT(GETDATE(), 'MM-dd-yyyy HH:mm:ss') --<< more conventionally with minutes
SQL Server Date Styles (formats) using CONVERT()
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.