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 2000 Forums
 SQL Server Development (2000)
 datetime query

Author  Topic 

nilaavu
Starting Member

18 Posts

Posted - 2005-12-17 : 22:59:24
I have a TIMEIN and TIMEOUT smalldatetime field

In my sp I have
SELECT convert(VARCHAR ,TIMEIN, 8) ,convert(VARCHAR ,TIMEOUT, 8) , DATEDIFF(n, TIMEIN, TIMEOUT) as DURATION

Here if the TimeOut field is 00:00:00 then I dont need to find out the duration , it can be blank or 00:00:00

How can I get this work inside my query?

thanks

SamC
White Water Yakist

3467 Posts

Posted - 2005-12-17 : 23:19:29
quote:
Originally posted by nilaavu

Here if the TimeOut field is 00:00:00 then I dont need to find out the duration , it can be blank or 00:00:00

How can I get this work inside my query?

[CODE]
SELECT convert(VARCHAR ,TIMEIN, 8) ,
convert(VARCHAR ,TIMEOUT, 8) ,
CASE WHEN CONVERT(VARCHAR, TIMEOUT, 8) = '00:00:00'
THEN '00:00:00'
ELSE DATEDIFF(n, TIMEIN, TIMEOUT)
END as DURATION[/CODE]

Go to Top of Page
   

- Advertisement -