Subscribe to Subscribers

Forums » .NET » SQL Server »

How to show date diff whn the time column is null???


Posted Date: 29 Jul 2012      Posted By:: vish     Member Level: Silver    Member Rank: 1641     Points: 5   Responses: 3



Hi,

In my table i have one (first open time) column and (closed time) column.
I want to show (closed time - first open time) in (AHT) column.

For this i have used :

convert(varchar(10),(cast(dateadd(second, datediff(second,[First Open Time], [Closed Time] ), 0) as time)),108)as AHT

But the problem is whenever first open time has null value it showing null in AHT column also.

But i want a value in AHT column. So how will i get.
For eg:
08:13:07 AM - null = 08:13:07 AM

I want to show like this.

So guys pls give any suggestion.

Thanks in advance....




Responses

#682335    Author: RayalaHariKishore      Member Level: Gold      Member Rank: 52     Date: 29/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

hi,

first you need to check if the values are null or not if null then make it as 0 and then perform the diff operation.

Rayala HariKishore

try..try..try...you achieved it.
http://rayalaharikishore.wordpress.com/


 
#682356    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 30/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

You need to check first that if the values for the time column are null then please insert the 00:00:00 values in the table.

This will help you in avoiding the error.

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM


 
#682369    Author: kirthiga      Member Level: Gold      Member Rank: 220     Date: 30/Jul/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi vish,

Try this it may help you


convert(varchar(10),(cast(dateadd(second,datediff(second,[First Open Time],
isnull([Closed Time],[First Open Time])),0) as time)),108)as AHT





 
Post Reply
You must Sign In to post a response.

Next : Write queries to get all the sub employees of particular employee
Previous : How to convert from varchar to datetime datatype
Return to Discussion Forum
Post New Message
Category:

Related Messages

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.