What's the SQL Server 2012 data type for '2014-06-30T11:00:00Z' ?

Hi guys

I'm working with a file that has dates formatted like '2014-06-30T11:00:00Z'.  
Is there a specific data type that holds these values, or do I just CAST it as a char, remove the T and Z, and cast that as a datetime?

LVL 66
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAsked:
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.

Brian CroweDatabase AdministratorCommented:
That looks like a DATETIME to me.  I don't see a timezone offset so I would just use STUFF to replace the "T" with a space and REPLACE the "Z" with an empty string and CONVERT to DATETIME

BTW the CONVERT style you would want to use would be 120
HuaMin ChenProblem resolverCommented:
select cast(replace(replace('2014-06-30T11:00:00Z','T',' '),'Z','') as datetime)
Anthony PerkinsCommented:
That would be the datetimeoffset data type as it combines the date, time and zone offset.

Incidentally the author is using the ISO 8601 date format which includes the time zone.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Vikas GargBusiness Intelligence DeveloperCommented:

no need to worry it will work as datetime format.

You dont need to cast or convert .

The same will be stored in sql as datetime
Anthony PerkinsCommented:
no need to worry it will work as datetime format.
The datetime data type does not support time zones.  So if they need this, as the example in the question clearly shows, then they need to use the datetimeoffset data type and not datetime.

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
Scott PletcherSenior DBACommented:
If you want to reformat it, remove the dashes and Z, and replace the T with a space:

SELECT REPLACE(REPLACE(REPLACE(datetimeoffset_string, '-', ''), 'T', ' '), 'Z', '')
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Thanks Tony.

All:  Tony's answer was the only one that defined the T and Z, which is what I was looking for, and not just to strip them and use a datetime.
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

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.