how to add time

Cholotron 161 Reputation points
2020-10-07T15:35:23.72+00:00

Good Morning,

I have two fields
tran_in (deatetime) = "2020-09-21 15:42:39.000"
tran_desc2 (char(30)) = "00:03:59"

I need to add these two fields

Thank you !!!

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,517 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tom Cooper 8,461 Reputation points
    2020-10-07T16:26:39.887+00:00
    Declare @Sample Table(tran_in datetime, tran_desc2 char(30));  
    Insert @Sample(tran_in, tran_desc2) Values('2020-09-21 15:42:39.000', '00:03:59')  
    Select tran_in, tran_desc2, DateAdd(second, DateDiff(second, '19000101', tran_desc2), tran_in) As SummedDate  
    From @Sample;  
    

    Tom

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Viorel 109.9K Reputation points
    2020-10-07T16:28:50.66+00:00

    Check a sample:

    declare @example as table ( tran_in datetime, tran_desc2 char(30) )
    
    insert into @example values ( '2020-09-21 15:42:39.000', '00:03:59' )
    
    select *,
        tran_in + tran_desc2
    from @example
    
    2 people found this answer helpful.