---------------------
| ID | date |
|-----+-------------|
| 1 | 2013-12-30 |
| 2 | 2014-01-03 |
| 3 | 2014-02-02 |
---------------------
column ID is int type
column date is Date type
When i use SELECT CAST (getdate() as date) currentDay, ID FROM table WHERE date >= GETDATE(), it only returns:
--------------------------------------
| currentDay | ID | date |
|---------------+------+-------------|
| 2013-12-30 | 2 | 2014-01-03 |
| 2013-12-30 | 3 | 2014-02-02 |
--------------------------------------
it does not return the row with ID=1.
In other words, >=GETDATE() does not return rows with today's date.
What did I do wrongly?
It doesn't return any rows with today's date because
GETDATE()gives date and time. So, in your example, converting2013-12-30to aDATETIMEgives you2013-12-30 00:00:00, which isn't equal or greater than2013-12-30 12:09:35(the result ofGETDATE()for me in this moment). You need to use:WHERE date >= CONVERT(DATE,GETDATE())