Hi all,This is a theoretical question to assist me with designing a schema. I have a table of targets that a person must achieve within a set time period (e.g. user must have completed a training package within 6 months from today).So I have the following schema:ID int PKUserID int FKTargetDesc nvarcharTargetSet datetime -- the day that the target was setCompletionD int -- how many days from today the user has to complete their targetCompletionM int -- how many months from today the user has to complete their targetCompletionY int -- how many years from today the user has to complete their targetCompleted bit
In a year's time, I need to run a SELECT statement to find out which targets are incomplete. Is it possible to do three DATEADD functions on a value in one operation? e.g. would this work?SELECT t.TargetDesc, u.userIDFROM tblTargets t INNER JOIN tblUsers u ON t.userID = u.userIDWHERE (t.Completed = 0) AND (DATEADD (Day, CompletionD, DATEADD (Month, CompletionM, DATEADD (Year, CompletionY, t.DateSet))) >= getDate())
If I had a couple of hundred rows that were being selected, would it be too much of a performance hit performing the DATEADD function three times per row? Would it be best to calculate the overdue date in a new column in each row instead?