sql server 2008 r2 - Get yesterday's rows startign from 10AM -
for previous day used use below expression .
date_inserted >=dateadd(day, datediff(day,0,getdate())-1,0) , date_inserted < dateadd(day, datediff(day,0,getdate()),0)
how rows yesterday 10am today 10am
-- yesterday @ midnight: declare @yesterday datetime = dateadd(day,datediff(day,1,getdate()),0); select ... date_inserted >= dateadd(hour, 10, @yesterday) -- 10 yesterday , date_inserted < dateadd(hour, 34, @yesterday); -- 10 today
Comments
Post a Comment