SQL Query - Get Date Range

I want to return a recordset of results from just today ie:

SELECT * FROM tblLogUser WHERE LogDate =getDate()

getDate() includes the time, which I don't want, so how do I easily filter that out?
equentinAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
if logdate contains no time portion:
SELECT *
FROM tblLogUser
WHERE LogDate = convert(datetime, convert(varchar(10),getDate(),120), 120)

if log date does contain time portion:

SELECT *
FROM tblLogUser
WHERE LogDate >= convert(datetime, convert(varchar(10),getDate(),120), 120)
AND LogDate < dateadd(day, 1, convert(datetime, convert(varchar(10),getDate(),120), 120))

0
 
equentinAuthor Commented:
Okay, that's kind of what I had already (it does have date portion), but I was wondering if there was anything a little more elegant.  Cheers!
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
not really.
I have on may servers/database a view/function that returns only the date portion, so it can be used in views/functions easily
0
 
equentinAuthor Commented:
Sorry, just noticed I hadn't accepted the solution - my apologies.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.