Solved

Date comparison in SQL Server 2008

Posted on 2014-03-04
1
567 Views
Last Modified: 2014-03-04
Hi all.

I have a SQL Server 2008 query as follows:

SELECT     Expired, ExpirationDate
FROM         myTable
WHERE     (ExpirationDate < { fn NOW() })

Open in new window


The problem is, if the expiration date is 2014-03-04 it appears in the results when compared to today. The ExpirationDate field is a date Data Type. What am I doing wrong? Do I need to format NOW()?

Thank you in advance.
0
Comment
Question by:printmedia
1 Comment
 
LVL 15

Accepted Solution

by:
tim_cs earned 500 total points
ID: 39903413
Cast now as a Date.

CAST(GETDATE() AS DATE)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now