sql date

Is there a way to convert 20150908  (int) to date 09/08/2015 ?
Who is Participating?

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

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.

Russ SuterSenior Software DeveloperCommented:
CAST('20150908' AS Date)

Or if it's an INT data type you just cast it to a string before casting it to a date like this:

DECLARE @dateInt int = 20150908
DECLARE @TheDate date = CAST(CAST(@dateInt AS varchar) AS Date)
PRINT @TheDate
First cast your int to a string, then the string to a date, THEN... use the CONVERT function to conver the date to mm/dd/yyyy
declare @date int = 20150908

select CONVERT(varchar(10), cast(cast(@date as varchar) as datetime), 101)  --new date format

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
Jim HornMicrosoft SQL Server Data DudeCommented:
MlandaT's answer above is correct, but just for kicks and giggles define 'convert' in your question.
If you mean 'just display it as', then we're good to go.
If you mean 'save it in the database as', then explain this in greater detail.

btw PortletPaul's article SQL Server Date Styles (formats) using CONVERT() is an excellent resource for date formatting.
VBdotnet2005Author Commented:
Thank you
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 2005

From novice to tech pro — start learning today.