Showing data from a shift that covers two days [message #1837827] |
Mon, 08 February 2021 11:16 |
Chris Percival Messages: 1 Registered: February 2021 |
Junior Member |
|
|
Hello Experts,
I have a problem with filtering data to display. In the factory where I work, we have 8 robot welding cells which have their production figures collected and synced to an sql server 2017 database. I am attempting to setup a report so that when the user selects a shift (Morning, Afternoon, Night) and a date, they have exactly that in the report.
The problem lies in the night shift, from 22:00 to 06:00 which means for any given date the data consists of the last six hours of the previous days shift (00:00-06:00) and the first two hours of the shift being asked for.
The parameter for choosing which shift is a static radio list of three entries (Morning, Afternoon, Night). So the query takes the shift and the date like so:
SELECT * FROM redlion_CELLS Where ? like ActiveShift And ? like [TimeDate]
Which is fine for Morning and Afternoon shifts, but for night shift, I would need a query such as:
SELECT * FROM redlion_CELLS where activeshift = ? and [DateTime] between '2021-02-01 22:00:00.000' and dateadd(hh,8,'2021-02-01 22:00:00.000')
Which sums up what I am trying to achieve. Ultimately though, I want the user to be able to select a shift and a date and get the correct data no matter what shift is choasen and without any further user input.
Could anyone put forward a suggestion to help me reach my goal please
|
|
|
Powered by
FUDForum. Page generated in 0.03384 seconds