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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to combine date and time column?

Author  Topic 

hkben
Starting Member

4 Posts

Posted - 2007-08-20 : 01:29:27
I have one column date and another column with time.
How can i combine both into single column with date and time?

FDATE FTIME
20060101 063616
20060101 070743

CREATE TABLE payment2 (
FDATETIME Datetime
FTIME Character(12));

INSERT INTO payment2 values ('20060201', '164044');
INSERT INTO payment2 values ('20060201', '175914');

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-20 : 01:45:16
Why dont you use just DATETIME datatype and then seperate time from date when needed?
Here is one of the methods
select 
FDATETIME,
FTIME,
dateadd(second,cast(ftime as int)/10000*3600+
cast(ftime as int)/100%100*60+
cast(ftime as int)%100,fdatetime) as date_time
from payment2


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-20 : 01:46:24
and this forum is to post workable scripts and not to ask a question

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hkben
Starting Member

4 Posts

Posted - 2007-08-20 : 02:05:40
Thanks, I will move the question to other place.
The data i extract from the Point of Sales has two columns.
But I need a single column with format "mm/dd/yyy HH:MM:SS" when i import into SQL for my BI project.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 04:27:34
Cross posting too
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88058



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -