Do you have to include future dates in your outbound documents, but your back end system will not create them in your input file? What can one do to create these dates during translation?
Relax; you can use “Date Math” to solve your problem!
What is this “Date Math” I speak about? Well it is nothing more than the extended rule Operator “>> “ used for Date modification.
Simply by using an extended rule as such:
#requested_date_field = #shipped_date_field << days(n);
you can add any (n) number of days to a date field.
If you wish to subtract days from a date field, the integer inside the parenthesis (n) will be a negative (-n).
So let’s use this in an example.
You currently have only the date your customer’s order will ship, but you also have to include the expected delivery date. You know from previous deliveries it will take 3 days to go from your warehouse to the customer’s distribution center. The two fields in your map which will hold the date are:
The extended rule then will be:
#Expected_Delivery_Date = #Date_Shipped <<days(3);
If our Date_Shipped was 09/14/2014 our Expected_Delivery_Date would be 09/17/2014.
Now let’s say your partner will only accept delivery on weekdays. So Saturday and Sunday the distribution center will not be open to receive shipments. To make sure you avoid this situation, you will have to first find out the day of the week you are shipping, and then if the third day from when you shipped is either Saturday or Sunday, you will have to add an additional one or two days so the Expected Delivery will be on the following Monday.
string day_of_the_week; //Will return the actual day of the week the date occurs
day_of_the_week = ""; //initialize the variable
//add 3 days
#Expected_Delivery_Date = #Date_Shipped_ << days(3);
//convert the new date to a 3 character string
//SUN, MON, TUE, WED, THU, FRI, or SAT
//Check the value to see if we need to add 1 or 2 days for the weekend
if day_of_the_week = "SAT" then
#Expected_Delivery_Date = #Expected_Delivery_Date << days(2);
if day_of_the_week = "SUN" then
#Expected_Delivery_Date = #Expected_Delivery_Date << days(1);
//If it is neither Saturday or Sunday then the original value for the Expected_Delivery_Date will be retained in the data.
You can do other conversions for dates, such as months and years. You would simply substitute months(n) or years(n) in the rule. So go ahead and ship your goods and take the weekend off!