• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • 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

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

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