Solved

All rows today

Posted on 2011-09-09
2
297 Views
Last Modified: 2012-05-12
I have a table. It has a column DateCreated (datetime). I would like to select all rows where DateCreated is today. How is best to do that?
0
Comment
Question by:johnkainn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 125 total points
ID: 36513737
SELECT *
FROM SomeTable
WHERE DateCreated >= DATEADD(day, DATEDIFF(day, '2000-01-01', GETDATE()), '2000-01-01') AND
    DateCreated < DATEADD(day, DATEDIFF(day, '2000-01-01', GETDATE()) + 1, '2000-01-01')

Open in new window

0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36513741
If you can guarantee that DateCreated never has a time portion, you can get away with:

SELECT *
FROM SomeTable
WHERE DateCreated = DATEADD(day, DATEDIFF(day, '2000-01-01', GETDATE()), '2000-01-01')

Open in new window

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question