Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Speed of DATEPART

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I am currently using DATEPART to return a list of birthdays for a particular month in a stored procedure. The SP accepts a parameter @Month INT - and the DATEPART query is as follows:

WHERE DATEPART(MONTH, Employee) = @Month.

Apparently, DATEPART is quite an intensive query - and I need to optimise this query as much as possible. Does anyone have any suggestions for me on how to do this? Someone has suggested to me that a BETWEEN clause should be used instead of DATEPART - but I can't see how this could work for a list of birthdays for a particular month.

Thanks as always

Craftor
:cool:
 
You could create a field to store the birthday month but I don't think the datepart function is your problem. If the table is large then perhaps an index would be the best answer. The between should work if there is an index on the birthday column.

JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top