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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -