Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 GetDate() function not returning correctly

Author  Topic 

Lorna70
Starting Member

19 Posts

Posted - 2010-02-26 : 04:58:26
I have an sproc which should return a record with todays date but it doesn't. My sproc is as follows:

SELECT * FROM vEventsList
WHERE Venue_Id = 1
AND Date_From >= GETDATE()
ORDER BY DATE_FROM
RETURN

This returns all records with Date_From > today but not any with today's date. This is really wierd! I tried running it without the > to see if it would return an event with Date_From of today but that doesn't work either! please please help!

Sachin.Nand

2937 Posts

Posted - 2010-02-26 : 05:00:32
quote:
Originally posted by Lorna70

I have an sproc which should return a record with todays date but it doesn't. My sproc is as follows:

SELECT * FROM vEventsList
WHERE Venue_Id = 1
AND Date_From >=dateadd(dd,datediff(dd,0,getdate()),0)
ORDER BY DATE_FROM
RETURN

This returns all records with Date_From > today but not any with today's date. This is really wierd! I tried running it without the > to see if it would return an event with Date_From of today but that doesn't work either! please please help!




PBUH
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-26 : 08:09:09
the reason is getdate() returns time part also so > will only return records created after current date and current time

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -