Hi Expert,
Guys, i need your help on how to do a script calculating the totalDays
using the formula (see below). i have to calculate the totaldays based on
different Supplier and Rtype and also if the totalday is less than the warranty period i have to indicate it as "YES" in warranty decision if greater than i will place a "NO"
Create Table MyTable
(ESN nvarchar(35),
Supplier nvarchar(35),
RType nvarchar(10),
WarrantyPeriod int,
TodaysDate datetime,
Returndate datetime,
Receivedate datetime,
TotalDays int,
WarrantyDecision nvarchar(5)
)
Insert into Mytable
Values('123','AC8','CRA','180','2011-18-2011','2011-04-29','2011-03-03')
Values('124','BEI','CRA','180','2011-18-2011','2011-04-29','2011-03-22')
Values('125','JAB','CRA','180','2011-18-2011','2011-04-30','2011-03-31')
Values('126','FIH','RA','180','2011-18-2011','2011-04-30','2011-01-17')
RESULT:
123--AC8--CRA--180--'2011-18-2011--2011-04-29--2011-03-03--19--YES
124--BEI--CRA--180--'2011-18-2011--2011-04-29--2011-03-03--19--YES
125--JAB--CRA--180--'2011-18-2011--2011-04-30--2011-03-31--45--YES
125--FIH--CRA--180--'2011-18-2011--2011-04-30--2011-01-17--118--YES
Formula:
AC8-BEI/CRA
Totaldays = TodaysDate - Returdate
JAB/CRA
Totaldays = TodaysDate - ReceiveDate
FIH/CRA
Totaldays = TodaysDate - ReceiveDate
Thank yu in advance.
Regards,
Jonel