Taking A Date and Subtracting Days

Questions, tips and tricks and techniques for scripting in Servoy

Taking A Date and Subtracting Days

Postby itgenetics » Thu Feb 02, 2012 12:28 pm

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.
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK

Re: Taking A Date and Subtracting Days

Postby ROCLASI » Thu Feb 02, 2012 1:07 pm

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Taking A Date and Subtracting Days

Postby itgenetics » Thu Feb 02, 2012 1:20 pm

Hi there, which function of that plugin would you use? array?
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK

Re: Taking A Date and Subtracting Days

Postby jdbruijn » Thu Feb 02, 2012 3:55 pm

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)
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Taking A Date and Subtracting Days

Postby itgenetics » Thu Feb 02, 2012 3:57 pm

Thank you very much. Checking it our now . .
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK

Re: Taking A Date and Subtracting Days

Postby omar » Fri Feb 03, 2012 4:58 pm

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));
}
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands


Return to Methods

Who is online

Users browsing this forum: Bing [Bot] and 13 guests