Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 CHAR TO DATETIME
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

egemen_ates
Yak Posting Veteran

Turkey
76 Posts

Posted - 03/22/2013 :  08:50:09  Show Profile  Reply with Quote
Hello Myfrined

i have two column

E_DATE E_TIME
20130322 081104

How can i convert datetime using two columns

result is 2013-03-22 08:11:04.000

thank you

webfred
Flowing Fount of Yak Knowledge

Germany
8781 Posts

Posted - 03/22/2013 :  09:26:18  Show Profile  Visit webfred's Homepage  Reply with Quote
http://www.sqlservercurry.com/2011/09/sql-server-concatenate-date-and-time.html


Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 03/22/2013 :  09:36:23  Show Profile  Reply with Quote
DECLARE @tabDate TABLE( E_DATE CHAR(8), E_TIME CHAR(6))
INSERT INTO @tabDate VALUES('20130322', '081104')

SELECT CAST ( E_DATE + ' ' + STUFF(STUFF(E_TIME, 3, 0, ':'), 6, 0, ':') AS DATETIME2) FROM @tabDate


--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000