Yeah , your're right I have in the birth column 05/22/2008 12:00:00 AM. So I changed the select statment to convert it less the time to just 05/22/2008. The return results are 2008-05-22 and It's still not sending the email, the email works because it works when I just execute the dbo.sp_send_dbmail code.
The
procedure:
Code:
USE [peebman]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_proc_happyBirthday2]
AS
SET NOCOUNT ON
declare @birth datetime
declare row cursor for
--select @birth = (select birth from email where birth = birth))
select convert(varchar(10), birth, 120) from email --where birth = birth
open row
fetch row into @birth
while @@fetch_status = 0
begin
fetch row into @birth
end
close row
Deallocate row
return
--END
--BEGIN
IF @birth = convert(varchar(10), getdate(), 120)--getdate()
Begin
declare @body1 varchar(100)
set @body1 = 'You belong in a zoo!'---'Server :'+@@servername+ EXEC msdb.dbo.sp_send_dbmail
--@profile_name = 'david'
@recipients ='peebman@peebman.com', --
--@BCC = @BCCList,
@subject = 'My Mail Test',
@body = @body1,
@body_format = 'text';
end

Originally Posted by
jmurrayhead
As of today, getdate() returns 5/22/2008...however, you might have stored in your database 5/22/1976. Those dates do not match. If this is how it's setup, then you need to use some date functions to get only the month and day, not the year.
Bookmarks