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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 getdate () command

Author  Topic 

eashoori
Starting Member

22 Posts

Posted - 2009-04-06 : 14:30:41
I am trying to incorporate getdate() command in my query and I have used this numerous times out of my database. However when I put in actual today's date 04/06/09, it retrieves my data, but when I try getdate() command, it returns nothing. Do we have any other than current_timestamp, getdate() or getudate() to retrieve data against today's date in SQL 2000?

Thank you,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-06 : 14:54:10
It's probably because getdate() returns the time also. You'll need to strip off the time.

WHERE YourColumn >= DATEADD(Day, DATEDIFF(Day, 0, GetDate()), 0)
AND YourColumn < DATEADD(Day, DATEDIFF(Day, 0, GetDate())+1, 0)


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

eashoori
Starting Member

22 Posts

Posted - 2009-04-06 : 15:03:02
Thank you Tara, I tried getdate > ()-1 and surprisingly it worked! You are also right about the time stamp,
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-07 : 01:59:38
quote:
Originally posted by eashoori

Thank you Tara, I tried getdate > ()-1 and surprisingly it worked! You are also right about the time stamp,


However getdate > ()-1 is not the correct answer. Use above suggested method

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -