By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

DateDiff function in SQl written in VB

P: 19
Hi All,

I am getting an error saying that now() is not a reconized function in my datediff function would any one know why it is not being reconized?

Thanks for the help
-------------------------------------------------------------------------------------------------------------
USE Master

EXEC xp_startmail 'outlook', 'drive8'

Use inv_tracking

Declare @MyRecipients nvarchar (50)
declare @expirery_date datetime
declare @EmpID int(4)

Set @MyRecipients = 'derek.kemp@pesl.com'

Declare MyCursor Cursor For

select EmpID, expirery_date from driver_licence_abstract where DateDIFF('d',now(), expirery_date) < 90

Open MyCursor

Fetch Next From MyCursor Into @EmpID, @expirery_date

While @@Fetch_Status = 0

BEGIN
Set @MyMessage = 'Please be advised that : ' + @EmpID+ '.
Drivers Licence will expire in 3 months. Please Notifie the Branch Mangers.
The experation date is : '+ @expirery_date + '.'


Exec master.dbo.xp_sendmail @MyRecipients, @MyMessage

Fetch Next From MyCursor Into @EmpID, @expirery_date

End

Close MyCursor

Deallocate MyCursor
Jun 2 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 487
You have to try with getdate() in Sql Server.
Jun 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.