Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax needed to show difference in date/time fields...

Status
Not open for further replies.

cjohnson6

Technical User
Jul 19, 2000
21
0
0
US
I am trying to create the syntax (stored procedure) that will allow me to first check the status of a given date field, and if that date field is OLDER than 1 year (365 calendar days), I'll print out a statement and update the appropriate table(s).
Can anyone assist me with this task?

Here is a sample of the syntax I have so far:

CREATE PROCEDURE [spCheck_LastUpdate]

@last_updated datetime

AS
(SELECT B.last_updated from t_candidate1 B where last_updated = @last_updated)


*The above syntax I have only performs the 'check' on the last_updated field. How do I show or check to see if this last_updated field is older than 1 year?

Thanks in advance,
Claude Johnson
cjohnson@staffmentor.net
 
This checks for one year, can be modified to check for days instead.
SELECT B.last_updated
from t_candidate1 B
WHERE DATEDIFF(year, last_updated, GETDATE()) > 0

 
Thanks Malcolm. That worked out great. I really appreciate your help and speedy response. I've found the folks in this forum are really cordial and helpful.

Claude
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top