Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 7th, 2010, 10:18 AM
Authorized User
 
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in Finding Hours Duration Between two Dates

Hi to All Forum members


I am stuck in finding duration and Net duration in the following procedure


I also adding image Url for better under standing of my requirement.

Please go to this Url ..

http://picasaweb.google.com/lh/photo/203UnHt9l8EnouLOtIKxBg?authkey=Gv1sRgCM6puf-sutfJ2QE&feat=directlink


Following is my T-Sql Query...


Code:
Select F.Id as [FleetID], Convert(varchar(30), F.AssignedOn, 113) as [Date], D.DepotName as [Depot], DT.DutyID as [Duty Number],     
                IsNull(Convert(varchar(30), F.ActualOutSheddingTime, 113),'Not Assigned') as [Actual OutShedding Time],
                IsNull(Convert(varchar(30), F.ActualInsheddingTime, 113) ,'Not Assigned') as [Actual Inshedding Time],
                IsNull(CONVERT(varchar(5), DATEADD(ms, DATEDIFF(ms, F.ActualOutSheddingTime, F.ActualInsheddingTime), 0), 114) ,'00:00')as [Duration],
                IsNull(DT.RestHours, 00) as [ShiftChangeoverTime],
                IsNull(CONVERT(varchar(5), DATEADD(ms, DATEDIFF(ms, CONVERT(varchar(5), DATEADD(ms, DATEDIFF(ms, F.ActualOutSheddingTime, F.ActualInsheddingTime), 0), 114), Convert(Datetime, '00:'+ IsNull(Convert(varchar(30), DT.RestHours, 114), 30))), 0), 114),'00:00') as [Net Duration]
                From  Fleet F     
                Left Outer Join  Duties DT on  F.DutyID =  DT.ID             
                Inner  Join  Depot D on DT.DepotId = D.ID                
                Inner Join Vehicles V on V.ID = F.VehicleID




Welcome for your valuable suggestions.

Vishnu

Last edited by vishnu108mishra; January 7th, 2010 at 10:35 AM..
  #2 (permalink)  
Old January 7th, 2010, 10:22 AM
Authorized User
 
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ref : Problem in Finding Hours Duration Between two Dates

Hi

Actually Duration is coming right in this query and the issue is Net Duration is not coming right.


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem getting the last 4 dates smiter SQL Language 3 January 16th, 2007 05:19 AM
duration between dates rjkulkarni2001 Classic ASP Basics 1 January 5th, 2006 07:19 PM
Calculating hours and minutes between to dates timmaher Access VBA 4 May 10th, 2005 07:36 AM
Finding oldest to newest dates hcweb Classic ASP Basics 8 February 23rd, 2004 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.