Calculating 15 month old records

Last Post 24 Aug 2007 06:25 AM by SwePeso. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
sschmid4
New Member
New Member

--
24 Aug 2007 04:46 AM
I have a table of records in which every morning, I want to update the records which have a start_date older than 15 months and set them to inactive status.

I thought using a raw number of days might work in a simple math calculation

UPDATE tableA
SET active_yn = n
WHERE start_date < getdate()-450

But that doesn't work due to leap years or during february when there is only 28 days.
SwePeso
New Member
New Member

--
24 Aug 2007 06:25 AM
UPDATE tableA
SET active_yn = n
WHERE start_date < dateadd(month, -15, getdate())
sschmid4
New Member
New Member

--
19 Sep 2007 11:06 AM
This worked perfectly. Thanks for the help.
You are not authorized to post a reply.

Acceptable Use Policy