8,497
社区成员
发帖
与我相关
我的任务
分享
create proc [dbo].[proc_LMTodayBirthday]
as
begin
declare @t datetime
declare @i datetime
set @i = getdate()
exec fn_GetLunar @i ,@t output
--exec fn_GetLunar @i ,@t output
--這裡查詢的是另外一個系統中的數據
select emplid as empno ,name ,[description] deptname
from lmhr..EmplPostion as emp , lmhr..DIRPARTYINTERNALORGANIZATI2216 as dir
where emp.status = 1
and ((DATEPART(MM,emp.BirthDate) = DATEPART(MM,@t)
and DATEPART(dd,emp.BirthDate) = DATEPART(dd,@t)
and emp.birthdayFlag = 0)
or (DATEPART(MM,emp.BirthDate) = DATEPART(MM,@i)
and DATEPART(dd,emp.BirthDate) = DATEPART(dd,@i)
and emp.birthdayFlag = 1))
and emp.organizationunitid = dir.organizationunitid
order by empno
end