SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 subtract two Timestamp columns into day:hh:mm:ss
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ganesan
Starting Member

India
4 Posts

Posted - 08/13/2013 :  01:14:01  Show Profile  Reply with Quote
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

Sweden
30218 Posts

Posted - 08/13/2013 :  02:19:38  Show Profile  Visit SwePeso's Homepage  Reply with Quote
ALTER TABLE dbo.Table1 ADD RunningHours AS (DATEDIFF(SECOND, [Stop Date & Time], [Start Date & Time]) / 3600E);




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

ShivaKrishna
Starting Member

India
20 Posts

Posted - 08/28/2013 :  08:57:32  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000