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)
 newbie Question: Views

Author  Topic 

mmalaka
Starting Member

33 Posts

Posted - 2011-03-22 : 07:01:17
Hi Experts,

I am trying to create a view on a table. in this table I have 2 dates fields. in the view I want to show the difference between those fields..

So the fields in the table would be:
Table1{
Name,
Number,
LoggedDate,
ClosedDate
}

In the view I want to show
{
Name,
Number,
ResponseTime
}

The ResponseTime field should show ClosedDate - LoggedDate in Days (e.g. 5 Days)

Any advice please?
Thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-22 : 07:13:32
use DATEDIFF

SELECT
Name,
Number,
DATEDIFF(day,LoggedDate,ClosedDate) as ResponseTime

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -