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)
 SQL: How to select records by date between now and the a week's time.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-11 : 10:34:56
Martijn writes "I'm working on a little thing that should warn me when a friend is having his birthday. With the following select statement I'm trying to select all the records of people whose birthdat will be in the next 7 days from (now).

SELECT * FROM personen WHERE DATEDIFF(dd, DAY(persGeboorte), DAY(getdate()) ) < 7

However, this results in more than the expected number of records being selected.. In fact, it selects all records except the one dated 1-1-2001.

The daterecord is DD/MM/YYYY and the SQL server is SQL2000 on Windows 2000. The field containing the birthdate is 'persGeboorte'. Could you please help me out, oh SQL wonders? :)

Martijn"
   

- Advertisement -