Page 1 of 1

Taking A Date and Subtracting Days

PostPosted: Thu Feb 02, 2012 12:28 pm
by itgenetics
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.

Re: Taking A Date and Subtracting Days

PostPosted: Thu Feb 02, 2012 1:07 pm
by ROCLASI
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.

Re: Taking A Date and Subtracting Days

PostPosted: Thu Feb 02, 2012 1:20 pm
by itgenetics
Hi there, which function of that plugin would you use? array?

Re: Taking A Date and Subtracting Days

PostPosted: Thu Feb 02, 2012 3:55 pm
by jdbruijn
with the DateUtils plugin subtracting days is very straight forward, just use the addDays (or addMonths) function with a negative nr of days:
Code: Select all
_date = plugins.DateUtils.addDays(_deliveryDate, -10)

Re: Taking A Date and Subtracting Days

PostPosted: Thu Feb 02, 2012 3:57 pm
by itgenetics
Thank you very much. Checking it our now . .

Re: Taking A Date and Subtracting Days

PostPosted: Fri Feb 03, 2012 4:58 pm
by omar
This function also does the trick thanks to Juan:

Code: Select all
// 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));
}