Hello,
I'm trying to select a dayvalue in the sql statement depending on the openingstime.
So if the shop opens on 8:00 and the time is before that i want to show the times that it's open today.
If the actual time is after closing time i want to show the openingstime for the next day.
This is where i came so far...:
Is this possible or do i have to try it on a different way?
Thanks!
Regards,
Paul
I'm trying to select a dayvalue in the sql statement depending on the openingstime.
So if the shop opens on 8:00 and the time is before that i want to show the times that it's open today.
If the actual time is after closing time i want to show the openingstime for the next day.
This is where i came so far...:
Code:
SELECT customer_id, day_number, start_time_hour = ( start_time / 3600 ), start_time_minute = floor((( start_time / 3600.0 ) - ( start_time / 3600 )) * 60 ), end_time_hour = ( end_time / 3600 ), end_time_minute = floor((( end_time / 3600.0 ) - ( end_time / 3600 )) * 60 ) FROM office_hours WITH( NOLOCK) WHERE customer_id = 28 AND IF (SELECT DATEPART(hour, GETDATE())) > start_time BEGIN (day_number = (DATEPART(dw, GETDATE()+1) + 6) % 7) END ELSE BEGIN (day_number = (DATEPART(dw, GETDATE()) + 6) % 7) END ORDER BY day_number, start_time_hour, start_time_minute
Thanks!
Regards,
Paul
Comment