-1
select 
    datepart(mm, dbo.axfnGetOrgDate()) As orgmonth,
    datepart(mm, rtlposslip.salesdate) as orgmonth2 
from 
    rtlposslip (nolock)
where 
    rtlposslip.employeeusercode = 'DB@gmail.com' 
    and datepart(mm, rtlposslip.salesdate) = datepart(mm, dbo.axfnGetOrgDate())
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

If you really want to fetch the same month from each year, it's not so simple and most likely will not improve the performance because it's unlikely that index can be used if you'll add a lot of 1 month date ranges with or.

But if you're returning a lot of rows, the problem you have might actually be dbo.axfnGetOrgDate(), because it is being called separately for every single row the select returns.

James Z
  • 12,209
  • 10
  • 24
  • 44