Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-01-20 : 09:01:18
|
Hi All-Below is the case statement I have written to update a datetime(Deliverydt) feild based on three other feilds ot of which two are datetime feilds(approvedt,availabledt) and the third one(turndays) is a integer valueUpdate Customer_DeliverySet Deliverydt = CaseWhen availabledt is null then deliverydt = approvedtWhen availabledt > approvedt then deliverydt = dataavailable + [Turndays] business daysWhen approvedt > availabledt then deliverydt = approvedt + [Turndays] businessdaysElse uwapprovedtend Where reqno in () In the above query i would need help to add turndays feild to the date.the turndays value is an integer value that needs to be added as business days to the date taking into consideration that weekends are holidays and all weekdays are business daysThanksJim |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-01-20 : 09:12:01
|
how do i convert the turndays feild to businessdays.so for example if i have to add 10[turndays] to todaysdate(deliverydt)HopeI'm making sensequote: Originally posted by X002548 When availabledt > approvedt then deliverydt = dataavailable + [Turndays] business daysWhen availabledt > approvedt then deliverydt = DATEADD(dd,[Turndays],dataavailable)Brett
|
 |
|
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-01-22 : 22:14:35
|
| still waiting for help on my post |
 |
|
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2012-01-24 : 08:47:32
|
| found help for this post online in case someone might need this in futureUpdate Customer_DeliverySet deliverydt = CaseWhen availabledtis null then approvedt When availabledt > approvedt then DATEADD(day, Turndays%5 + CASE DATEPART(weekday,availabledt) + Turndays%5 WHEN 6 THEN 2 WHEN 7 THEN 1 ELSE 0 END, DATEADD(week,Turndays/5,availabledt))WHEN approvedt > availabledt then DATEADD(day, Turndays%5 + CASE DATEPART(weekday,approvedt) + Turndays%5 WHEN 6 THEN 2 WHEN 7 THEN 1 ELSE 0 END, DATEADD(week,Turndays/5,approvedt)Else approvedt end Where reqno in () |
 |
|
|
|
|
|
|
|