=> Trigger to calculate datediff
From: Rhonda Fischer (RhondaFischer_at_discussions.microsoft.com)
Date: 06/28/04
- Previous message: Nigel Rivett: "RE: Changing 100 table object owner names at once"
- Next in thread: Vishal Parkar: "Re: => Trigger to calculate datediff"
- Reply: Vishal Parkar: "Re: => Trigger to calculate datediff"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Jun 2004 07:02:01 -0700
Hello,
I am trying to create a trigger that will update the int table column: 'DaysLost'
based on the date difference between 'DateFrom' and 'DateTo' this will indicate
how many days an employee has been away ill.
Where the 'DateTo' datetime table column is null I have used the current_date
function. This is not quite working it's complaining of 'Incorrect syntax near ) '
Any ideas, would be terrific.
**********************************************************
CREATE TRIGGER trgCalculateLostDays ON [dbo].[Incident]
FOR INSERT, UPDATE
AS
UPDATE Incident
SET DaysLost = case when DateTo Is Null
then datediff("d", DateFrom, {fn current_date()})
else (datediff("d", DateFrom, DateTo) +1)
************************************************************
Thank you kindly
Rhonda
- Previous message: Nigel Rivett: "RE: Changing 100 table object owner names at once"
- Next in thread: Vishal Parkar: "Re: => Trigger to calculate datediff"
- Reply: Vishal Parkar: "Re: => Trigger to calculate datediff"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|