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
 General SQL Server Forums
 New to SQL Server Programming
 DATEDIFF function

Author  Topic 

JVisconti
Starting Member

47 Posts

Posted - 2009-09-17 : 15:21:56
I want to take a column called TicketOpenDateTime and a column called HistoryFirstResponse and use them in a DATEDIFF function to find out the time difference between when the ticket was opened and when the First Response was entered into the system. I need synatx help with this please.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-09-17 : 15:42:34
did you try books on line? If you have some code and are getting an error please post and someone can help

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

JVisconti
Starting Member

47 Posts

Posted - 2009-09-17 : 16:13:47
I have this piece of code:

SELECT
ResponseTime = HistoryFirstResponse-TicketOpenDateTime,
TicketOpenDateTime,
HistoryFirstResponse
FROM
(
select TicketOpenDateTime = convert(datetime,'20090916 23:59:00.000'),
HistoryFirstResponse = convert(datetime,'20090917 12:00:00.000')
)a


This places the information I am looking for in a new table when I want it to show as a new column in the same table as the data I'm looking through.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-09-17 : 16:41:40
I'm not sure I'm clear, but are you looking for something like the DATEDIFF function?
SELECT
DATEDIFF(MINUTE, TicketOpenDateTime, HistoryFirstResponse) AS ResponseTime,
TicketOpenDateTime,
HistoryFirstResponse
FROM
(
select TicketOpenDateTime = convert(datetime,'20090916 23:59:00.000'),
HistoryFirstResponse = convert(datetime,'20090917 12:00:00.000')
)a
Or are you asking how to display your resulting date?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-17 : 21:48:23
it is related to http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=132977


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

JVisconti
Starting Member

47 Posts

Posted - 2009-09-22 : 09:10:25
I am trying to display the new date/time in the Response time column. I now have the column created within the main query.
Go to Top of Page
   

- Advertisement -