Originally posted by: SystemAdmin
Based on a Microsoft solution at
http://support.microsoft.com/default.aspx?scid=kb;en-us;114946 the following will work if you are not adverse to using a lookup table.
Create the lookup table:
code:1:998e85cea9 DAYS LEFT TABLE
Day Started
Days Left Sat Sun Mon Tue Wed Thur Fri
0 0 0 0 0 0 0 0
1 0 1 1 1 1 1 0
2 1 2 2 2 2 1 0
3 2 3 3 3 2 1 1
4 3 4 4 3 2 2 2
5 4 5 4 3 3 3 3
6 5 5 4 4 4 4 4
[/code:1:998e85cea9]
I formatted mine as:
00000000
10111110
21222210
32333211
43443222
54543333
65544444
My type tree, DaysLeft.mtt, had 1:1 numeric fields per record.
I show two rules below for clarity. Rule 1 may be substituted in Rule 2 for ExtractedDaysLeftRecord.
Rule 1:
code:1:998e85cea9LOOKUP(Record:DaysLeft, TEXTTONUMBER(LEFT(NUMBERTOTEXT(Field:Record:DaysLeft), 1) ) = MOD(DATETONUMBER(EndDate) - DATETONUMBER(StartDate ), 7 ) )
/* Retrieve the table row where Column 1 equals the modulus of (End Date - Start Date) / 7 [/code:1:998e85cea9]
Rule 2:
code:1:998e85cea9 (INT( (DATETONUMBER(EndDate) - DATETONUMBER(StartDate) )/ 7) * 5 ) +
TEXTTONUMBER(MID(ExtractedDaysLeftRecord, MOD(DATETONUMBER(EndDate) - DATETONUMBER(StartDate), 7) + 1, 1 ) )
/* The number of working days equals the number of full seven week periods * 5 +
the table value corresponding to the column for the day of the week of the Start Date in the row corresponding to the remainder of the total elapsed days divided by seven[/code:1:998e85cea9]
#IBMSterlingTransformationExtender#IBM-Websphere-Transformation-Extender#DataExchange