I’d like to have a button to
If current time between 6am and 6pm, set time range to 6am-6pm.
If current time between 6pm and 6am, set time range to 6pm-6am.
This would allow someone to view an entire “current” shift window.
IF @currentHour >= 6 AND @currentHour < 18
BEGIN
– Zeitfenster von 6 Uhr bis 18 Uhr heute
SET @time_from = DATEADD(HOUR, 6, CAST(CAST(GETDATE() AS DATE) AS DATETIME)); – 6 Uhr heute
SET @time_to = DATEADD(HOUR, 18, CAST(CAST(GETDATE() AS DATE) AS DATETIME)); – 18 Uhr heute
SET @time_window = ‘6h - 18h’;
END
ELSE
BEGIN
– Zeitfenster von 18 Uhr bis 6 Uhr
IF @currentHour < 6
BEGIN
– Zeitfenster von 18 Uhr des vorherigen Tages bis 6 Uhr heute
SET @time_from = DATEADD(HOUR, 18, DATEADD(DAY, -1, CAST(CAST(GETDATE() AS DATE) AS DATETIME))); – 18 Uhr gestern
SET @time_to = DATEADD(HOUR, 6, CAST(CAST(GETDATE() AS DATE) AS DATETIME)); – 6 Uhr heute
END
ELSE
BEGIN
– Zeitfenster von 18 Uhr heute bis 6 Uhr morgen
SET @time_from = DATEADD(HOUR, 18, CAST(CAST(GETDATE() AS DATE) AS DATETIME)); – 18 Uhr heute
SET @time_to = DATEADD(HOUR, 6, DATEADD(DAY, 1, CAST(CAST(GETDATE() AS DATE) AS DATETIME))); – 6 Uhr morgen
END
SET @time_window = ‘18h - 6h’;
END
SELECT
CONVERT(BIGINT, DATEDIFF(SECOND, ‘1970-01-01’, @time_from)) * 1000 AS ‘time_from’,
CONVERT(BIGINT, DATEDIFF(SECOND, ‘1970-01-01’, @time_to)) * 1000 AS ‘time_to’, @time_window AS ‘time_window’
Can you check for those date time ranges using conditional logic and return required data accordingly?
Then add a Refresh interval of 5min or so and dashboard will refresh with 0 hutton
import "date"
startDateTime = make it today 6am
currentDateTime = now() or system.time()
date.add(d: 6h, to: 2019-09-16T12:00:00Z)
If currentDateTime between
If currentDateTime between
Etc