WHERE Date >= getdate()

I have a query where i am trying to get any record were the date is either today or greater than today

This is my query

WHERE EndDate >= getdate()

today's date is 2/29/2016 and it is not returning any records that are like this 2016-02-29 00:00:00.0000000

I suspect it is because of the time portion? how do i remove the time out of the equation.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
Numerous ways but I use this

WHERE EndDate >= cast(convert(nvarchar(10), getdate(), 103) as datetime)

Open in new window

You might need to alter the 103 to 101 depending on your date settings.
Lee SavidgeCommented:
You can also use this:

WHERE EndDate >= cast(getdate() as date)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kent OlsenDBACommented:
Hi coder,

It's probably due to the way things are being recast implicitly.  If you'll explicitly cast the value to the appropriate type you can get past it.

WHERE cast (EndDate as date) >= getdate()


WHERE EndDate >= cast (getdate() as {date type of EndDate})

If you have a lot of data, the second will be faster as the recast occurs on the static data, not the row data.  However, if the EndDate column is a string in 'mm/dd/yyyy' format you'll need to use the first form as a date string doesn't compare easily unless it's in 'yyyy-mm-dd' format.

Good Luck!
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Are you storing future dates in EndDate in your table?

If not, do you want to check this?

WHERE EndDate =< getdate()

Open in new window

awking00Information Technology SpecialistCommented:
What data type is end_date?
vbnetcoderAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.