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 2005 Forums
 Transact-SQL (2005)
 carving out time from Shifts

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-07-03 : 14:14:48
Greetings

Anywhere you can point me to for figuring out on how to carve out down time (with StartTime and EndTime) in a shift (with StartTime and EndTime). as you can see from this "graphical" representation x marks the spot where a certain down time occured after the shift ended. This x (minutes) should not be calculated in the net operating time

x this gap here needs to be substracted
Shifts |-------------------------------|x|---------------------------------------|
Down Times |-----| |-------| |-----------| |-------|

So I was wondering if you could please point me in the right direction

Thanks!!!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-03 : 21:10:07
how does your table looks like ?

post the table DDL, sample data and the required result


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

Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-01-23 : 13:24:12
back to this topic after almost a year. here is how the tables look

[tblDownTimeData](
[DownTimeID] [int] IDENTITY(1,1) NOT NULL,
[FromDownTimeDate] [datetime] NULL,
[ToDownTimeDate] [datetime] NULL,
[FromTime] [datetime] NULL,
[ToTime] [datetime] NULL,
[Comment] [nvarchar](200) ,
[SawID] [int] NULL,
[ShiftID] [int] NULL,
[DiscrepancyID] [int] NULL

[dbo].[Shifts](
[ShiftID] [int] IDENTITY(1,1) NOT NULL,
[BranchID] [int] NOT NULL,
[ShiftName] [varchar](20) ,
[ShiftDescr] [varchar](20) ,
[ShiftDayOfWeek] [int] NOT NULL,
[ShiftsComments] [varchar](200) ,
[ShiftStartDateTime] [datetime] NOT NULL,
[ShiftEndDateTime] [datetime] NOT NULL,
[ShiftActive] [bit]
Go to Top of Page

seanworking
Starting Member

13 Posts

Posted - 2009-02-11 : 00:24:17
I didn't realize half of something is almost the whole thing? Interesting logic.
Go to Top of Page
   

- Advertisement -