Taking A Date and Subtracting Days

Hi guys. A newbie question here. I have a delivery date which I have to make a critical path for so for example:

Delivery Date 31/12/12
Production Date 30/9/12
Delivery Date 30/6/12
Order Date 31/5/12

I have the number of days each date change uses in a global variable - but I do not have a clue how to set the fields to each of these dates. I have tried:

forms.dev_order_lines_table.sor_po_goods_in_critical_date = globals.bb_delivery_date - (globals.bb_parent_prod + globals.bb_parent_lead + globals.bb_child_prod)

but it doesn’t seem to work.

Your urgent help and assistance would be greatly appreciated.

Hi,

You might want to take a look at the DateUtils plugin from Patrick Ruhsert.
http://www.servoy-plugins.de/plugins/da … lugin.html

Hope this helps.

Hi there, which function of that plugin would you use? array?

with the DateUtils plugin subtracting days is very straight forward, just use the addDays (or addMonths) function with a negative nr of days:

_date = plugins.DateUtils.addDays(_deliveryDate, -10)

Thank you very much. Checking it our now . .

This function also does the trick thanks to Juan:

// VFP2Servoy Toolkit
// Function : GODATE()
// Author   : Juan Antonio Santana Medina
/**
* Returns a new Date adding nDays
* 
* @param {Date} dDate - Date to add/substract the nDays
* @param {Number} nDays - Number of days to add/substract to dDate
*/
function GODATE(dDate, nDays){
    var dTemp = new Date(dDate.valueOf());
    return new Date(dTemp.setDate(dTemp.getDate() + nDays));
}