Sample Table Structure:
Create Table [TestDate] (
[DateOfRegistration] [datetime],
[Gender] [char] (1)
) ON [PRIMARY]
Go
Sample records for testing
Insert into TestDate (DateOfRegistration,Gender) Values (getdate(),'M')
Insert into TestDate (DateOfRegistration,Gender) Values (getdate(),'M')
Method 1:
Select * from testdate where Convert(char(10),dateofregistration,101) = Convert(char(10),getdate(),101)
Method 2:
Select * from testdate where month(DateOfRegistration) = month(getdate()) and
day(DateOfRegistration) = day(getdate()) and
year(DateOfRegistration) = year(getdate())
Method 3:
Select * from testdate where datediff(d,dateofregistration,getdate()+1) = 1
I used to use the first method only almost always. But I have listed the other two methods which I know off for your reference. You could compare the performance benefits between the 3 methods and decide for yourself :)
Best Regards
Vadivel
MVP ASP/ASP.NET
http://vadivel.thinkingms.com