Solved

How do I combine a DATE ...and a TIME field so as to get a DATE/TIME FIELD...?

Posted on 2007-11-30
8
945 Views
Last Modified: 2010-04-21
Experts:

My data fields look like this:

calldatestamp      calltimestamp
2007-10-15 00:00:00.000      1900-01-01 08:39:34.000
2007-10-15 00:00:00.000      1900-01-01 08:41:15.000
2007-10-15 00:00:00.000      1900-01-01 08:50:47.000
2007-10-15 00:00:00.000      1900-01-01 09:12:52.000

I need to know how to combine these fields so as to acheive this:

calldatetimestamp
2007-10-15 08:39:34.000
2007-10-15 08:41:15.000
2007-10-15 08:50:47.000
2007-10-15 09:12:52.000

Thank you for your expertise and assistance...!

MikeV
0
Comment
Question by:MIKE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 20382673
A way to merge the columns would be:

UPDATE tbl
SET Date = Date + convert(char(8), Time, 108)
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 20382687
SELECT CONVERT(varchar,CallDateStamp, 112) +' ' +convert(char(8), Time, 108)
0
 
LVL 17

Author Closing Comment

by:MIKE
ID: 31411924
Thank you for the quick reply...this solution is what I was seeking...

MikeV
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 20383218
Hello CRXIuser2005,

I see you already accepted an answer.  If your two source columns are already defined as
datetime, then simply adding the two will give you the result you seek.

Regards,

Patrick
0
 
LVL 17

Author Comment

by:MIKE
ID: 20383268
NIce......Niiiiicccceeeee.

Thanks for the input...your solution is actually the one I needed...simply too....THANKS again for the added info..it is much appreciated!

MikeV
0
 
LVL 17

Author Comment

by:MIKE
ID: 20384995
hey Patrick...when I used your method...the YEAR is totally thrown off.....2007 is changing to 2115...???

Any ideas...?

MikeV
0
 
LVL 6

Expert Comment

by:PaultheBroker
ID: 20388137
Mike - this shouldn't happen - I thought it might be because of the different start bases of smalldatetime and datetime but this works fine:

declare @date smalldatetime, @time smalldatetime, @datetime datetime
set @date = '20071130'
set @time = '09:56:12:123'
set @datetime = @date + @time
select @datetime

BTW: if you find you have accepted the 'wrong' answer, the only ethical thing to do is to have the question reopened by posting a 'pointless' question in the support forum, so you can reward the correct answer properly.
0
 
LVL 17

Author Comment

by:MIKE
ID: 20389544
Enlight of the problems I'm having with your suggestion...I do think Anees' suggestion is what works best for me.....and is less labor intensive....thanks again for the added input...

MIkeV
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question