| Author |
Topic |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-14 : 13:19:00
|
| Difference of two datetime columns caused overflow at runtime.dateadd(ss,ISNULL(datediff(ss,0,starttime),0),startdate) AS mDateTimeINSERT INTO [TargetDB].[dbo].[tData]( tName, tID, tDateTimeStart, tDateTimeStop)SELECT T.tName, T.tID, tStart = dateadd(ss,ISNULL(datediff(ss,0,t.starttime),0),t.startdate), tStop = dateadd(ss,ISNULL(datediff(ss,0,t.stoptime),0),t.stopdate)FROM INSERTED T |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-12-14 : 13:33:02
|
This is what is causing your error..datediff(ss,0,launchtime) Maybe you just need this..(if you are trying to find the diff in seconds between launchtime and launchdate)datediff(ss,launchtime,launchdate) |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-14 : 13:40:24
|
| select dateadd(ss,ISNULL(datediff(ss,0,starttime),0),startdate) AS mDateTime from tTableThis works. however the first posted code is not working. keep getting the same error. |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-14 : 14:00:41
|
| start date and start time in separate table. I am trying put the date and time in one column (datetime column of the target table). |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-14 : 14:32:21
|
| INSERT INTO [TargetDB].[dbo].[tData](tName,tID,tDateTimeStart,tDateTimeStop)SELECTT.tName,T.tID,tStart = CONVERT(datetime, convert(varchar(10), StartDate, 101 ) + ' ' + convert(varchar(10), StartTime, 108 )),tStop = CONVERT(datetime, convert( varchar(10), StopDate, 101 ) + ' ' + convert(varchar(10), StopTime, 108 ))FROMINSERTED TThis worked.... |
 |
|
|
|
|
|