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 2008 Forums
 Transact-SQL (2008)
 subtract two Timestamp columns into day:hh:mm:ss

Author  Topic 

Ganesan
Starting Member

4 Posts

Posted - 2013-08-13 : 01:14:01
Hi experts, I'm new to sql coding,
i have 3columns in my table called start date&time, stop date&time and running hours.

in this i need the running hours column as computed column specification from stop date &time and start date &time.
please help me to do this by computed column specification.

Regards
Ganesan

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-08-13 : 02:19:38
[code]ALTER TABLE dbo.Table1 ADD RunningHours AS (DATEDIFF(SECOND, [Stop Date & Time], [Start Date & Time]) / 3600E);[/code]



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

ShivaKrishna
Starting Member

20 Posts

Posted - 2013-08-28 : 08:57:32
alter table Table1 drop column RunningHours
alter table add RunningHours AS (DATEDIFF(SECOND, [Stop Date & Time], [Start Date & Time]) / 3600E);
Go to Top of Page
   

- Advertisement -