Link to home
Create AccountLog in
Avatar of urthrilled
urthrilled

asked on

SQL 2005 - determine 60 days prior to Anniversary of Hire Date

I need to configure a notification to alert Managers when it is 60 days prior to an employee's Hire Date Anniversary.

When I extract the month and day from the Hire Date (it's a datetime field in SQL 2005) and then try to determine the amount of days from today, getdate(), the extracted month and day are now a string and can't calculate datediff....  I've tried converting it back to date, but then I get the year again and I don't want the year, just the difference in the days from the Anniversary of the Hire Date to today.


Thanks for any suggestions/help.
Avatar of oleggold
oleggold
Flag of United States of America image

why can't You calculated daydiff before conversion and then preform assign of @hiredate?
Avatar of urthrilled
urthrilled

ASKER

The datediff from a Hire Date would never be 60 days in the future and that's what I need is 60 days prior to the Anniversary of their Hire Date.

If there's a way to do a datediff against the month and day I could, I just don't know how to do that, do you?
ASKER CERTIFIED SOLUTION
Avatar of urthrilled
urthrilled

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
This gives me the day of the year.  I can then calculate the difference between the present day of the year against the Hire Date and create the 60 day prior notification that I need.