sql server - Fetching record of last 48 hrs from SQL -


i have table1 with columns datetime, id , status.

i call stored procedure after specific hours , want fetch records of last 48 non weekend hours.

i tried writing case each day of getdate().

i want know best way this.

to avoid weekends, can use case or other logic in where. logic isn't 100% clear on over weekend days. here approach:

where (datename(wk, getdate()) in ('sunday', 'monday', 'tuesday') , datetime >= dateadd(hour, 48 + 48, getdate()) ) or       (datename, wk, getdate()) in ('wednesday', 'thursday', 'friday') , datetime >= dateadd(hour, 48, getdate()) or       (datename , wk, getdate()) in ('saturday') , datetime >= dateadd(hour, 24 + 48, getdate()); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -