Get Today’s Rows From SQL Server CE Database



--Option 1
SELECT ttId FROM TimeTracker 
WHERE ttInStamp >=DATEADD(day, DATEDIFF(day,0,GETDATE()),0) 
AND ttInStamp < DATEADD(day, DATEDIFF(day,0,GETDATE())+1,0)
 

--Not that good Options
--Option 2
SELECT ttId FROM TimeTracker 
WHERE DATEADD(day, DATEDIFF(day,0,GETDATE()),0) = DATEADD(day, DATEDIFF(day,0,ttInStamp,0)
 

--Option 3
SELECT ttId FROM TimeTracker 
WHERE (
DATEPART(day,ttInStamp) =DATEPART(day,getdate())
And
DATEPART(Month,ttInStamp) =DATEPART(Month,getdate())
And 
DATEPART(Year,ttInStamp) =DATEPART(Year,getdate())
 
) 



 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s