x

how to calcalate idle time

my requirement maxim idle time calculale my table structure(table one table name(tb_BusDetails) my field busid, IMEI,VehicleRegisterNo

second table Busid, LogDateTime

already i calating datetimeday d:H:r:s

select a.LogDateTime , CAST(DATEDIFF(DAY ,a.LogDateTime, GETDATE()) % 24/7 AS NVARCHAR(50)) + ':' +

 CAST(DATEDIFF(HOUR ,a.LogDateTime, GETDATE())  % 24  AS NVARCHAR(50)) + ':' +
 CAST(DATEDIFF(MINUTE, a.LogDateTime, GETDATE()) % 60 AS NVARCHAR(50)) + ':'+
   CAST(DATEDIFF(SECOND ,a.LogDateTime, GETDATE())%60 AS NVARCHAR(50))  as Duration 

  from tb_VTSData as a inner join tb_BusDetails as b on a.BusID=1 


plz any one help urgent

more ▼

asked May 30, 2015 at 06:21 AM in Default

avatar image

priyamca3
39 4 6

plz urgent

May 30, 2015 at 06:22 AM priyamca3
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

how i calcalte maxim bus id `and my table structure(table one table name(tb_BusDetails) my field busid, IMEI,VehicleRegisterNo

second table Busid, LogDateTime

select a.LogDateTime , CAST(DATEDIFF(DAY ,a.LogDateTime, GETDATE()) % 24/7 AS NVARCHAR(50)) + ':' +

CAST(DATEDIFF(HOUR ,a.LogDateTime, GETDATE()) % 24 AS NVARCHAR(50)) + ':' + CAST(DATEDIFF(MINUTE, a.LogDateTime, GETDATE()) % 60 AS NVARCHAR(50)) + ':'+ CAST(DATEDIFF(SECOND ,a.LogDateTime, GETDATE())%60 AS NVARCHAR(50)) as Duration

from tb_VTSData as a inner join tb_BusDetails as b on a.BusID=1

more ▼

answered May 30, 2015 at 06:33 AM

avatar image

priyamca3
39 4 6

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2219

asked: May 30, 2015 at 06:21 AM

Seen: 59 times

Last Updated: May 30, 2015 at 06:33 AM

Copyright 2018 Redgate Software. Privacy Policy