• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

micrsoft, sql server, 2000, trigger to add minutes to dates

folks

I have a requirement  ,have table 1with the folowing following data

Priority      days
10      365
20      182
30      92
40      62
50      28
60      7
70      1

in my other table (work)is a field called startdate and priority,if i insert a record into this table then it must take the startdate and add the days based on each priority

i.e

woid              startdate                       priority                  enddate
1000                8-7-7                               70                     8-8-7     ( 8-7-7  +1 day)
1002                8-7-7                               10                    8-8-8    ( 8-7-7  +365 days)

can anybody help will with this pls
r
0
rutgermons
Asked:
rutgermons
  • 3
1 Solution
 
jogosCommented:
case priority when 70 then startdate + 1 when 10 then startdate + 10 end
0
 
jogosCommented:
I put 10 where it hat to be 365

case priority when 70 then startdate + 1 when 10 then startdate + 365 end
0
 
rutgermonsAuthor Commented:
how does it display in triiger form?
0
 
jogosCommented:
with my code you can vary the result

For triggering you must know very well what you want in case of insert, update or delete. Select from table 'inserted' to get your new value

CREATE TRIGGER trg_Mytalbe1_insert ON Mytalbe1
FOR INSERT
AS
insert ..... select case priority when 70 then startdate + 1 when 10 then startdate + 365 end
      FROM inserted



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now