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
 SQL Server Development (2000)
 Comparing Dates

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-05 : 08:08:40
Andy Lau writes "I always had a problem getting the date that matches with a date in the database. I have a database table with a column that contains the date/time. How can i write an SQL Statement to match all those records that has a date which is 1 day before today's date? Anyone can help me? Thanks :)"

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-04-05 : 08:38:06
double posted.....and answered already....


http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14622

Go to Top of Page

jackstow
Posting Yak Master

160 Posts

Posted - 2002-04-05 : 08:39:03
Look up DATEDIFF on Books Online - or more specifically;

SELECT * FROM MyTable WHERE DATEDIFF(day, MyDateColumn, getdate() ) = 1

********
Oh - I didn't notice the double posting..

Edited by - jackstow on 04/05/2002 08:40:38
Go to Top of Page
   

- Advertisement -