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
 SQL Server Administration (2005)
 Date/Time and Int addition

Author  Topic 

robert693
Starting Member

42 Posts

Posted - 2010-10-20 : 13:18:09
Hello,

I have a table with two fields, one App_DtTm is a date/time field and the other Duration is an int field. I need to add the Duration to the time part of App_DtTm to get an ending time. This is part of a BCP command and I have used the CONVERT function to break the time from the date in App_DtTm. The Duration field seems to be the duration in nanoseconds. I am able to get the duration in minutes by dividing it by 6000. Is there any way to add the time from App_dtTm to the Duration and get the result in a time format? Thank you for your help!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-20 : 13:27:02
you can use dateadd like

CONVERT(varchar(8),DATEADD(n,durationinmin,DATEADD(dd,-DATEDIFF(dd,0,App_DtTm),App_DtTm)),108)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

robert693
Starting Member

42 Posts

Posted - 2010-10-20 : 14:38:44
Thank you, you guys are great!
Go to Top of Page
   

- Advertisement -