Convert Datatime in MSSQL

How do I convert a datetime field in MSSQL to MMDDYY format?

I have a select statement that I need tihe date, not the time portion that is stored in teh database.

The SQL that I have is :

SELECT     TXT_Name, CONVERT(DATETIME, DA_ProfileCreationDate, 'mmddyy') AS Expr1
FROM         TBL_Main

The DA_ProfileCreationDate has stored a date in the format of 2011-12-08 10:35:13.063 and I need the format 120811.

Any Ideas?
us1975mcAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

TonyRebaCommented:
Trey:

CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]
0
TempDBACommented:
you need it as mm-dd-yy , you can get as
select convert(datetime,DA_ProfileCreationDate,110)

if mm/dd/yy then
select convert(datetime,DA_ProfileCreationDate,101)
0
TonyRebaCommented:
CONVERT(VARCHAR(8), DA_ProfileCreationDate,1) AS [MM/DD/YY]
0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

TonyRebaCommented:
101 will give you - mm/dd/yyyy   not YY
0
us1975mcAuthor Commented:
What I am needing is just mmddyy without the '-' or '/'
0
Scott PletcherSenior DBACommented:
As requested, in MMDDYY:

REPLACE(CONVERT(varchar(8), DA_ProfileCreationDate, 1), '/', '') AS [MMDDYY]
0

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
TonyRebaCommented:
Did you try :

CONVERT(VARCHAR(8), DA_ProfileCreationDate,1) AS [MM/DD/YY]

If you need no  '-' or '/'  then do as Scott suggests
0
TempDBACommented:
thanks tonyReba for correcting me with century part.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
date/time article I wrote:
http://www.experts-exchange.com/A_1499.html

will help you to understand ...
0
us1975mcAuthor Commented:
Thanks to everyone for the inputs.  I am learning a lot about datetime in SQL.  angelIII your article is WELL written and a great source of information.  ScottPletcher, you hit the hammer right on the nail.  Workd great!

Thanks to all.

just an old marine
0
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.