In a project i got 3 dataslots. 2 dates and 1 string.
Got 2 dates and what a number of days between those to in an string field (or other type if String does not work.
Date 1 = 03-01-2010
Date 2 = 01-01-2010
String 1 = 2
so there are 2 days between the dates.
OnChange of one of those days a string value has to be calculate the number of days between de dates fields.
How can i handle this
Hello Danny,
You may use the following pre/post script for your requirement:
====
var d1=jst.getDataSlotValue("Date1");
var d2=jst.getDataSlotValue("Date2");
var d3=d1-d2;
var d4=d3/(1000*60*60*24);
var d5=Math.round(d4);
jst.putDataSlot("numDS", d5);
=====
Where Date1, Date2 are the date dataslot and numDS is Number dataslot.
Thanks,
--Deepak
Deepak,
Thanks voor the quick reply!
But i'm sorry to say i still can't get it working.
I used this:
var d1 = sbm.util.getValue('endDate');
var d2 = sbm.util.getValue('tolerenceDate');
var d3 = d1-d2;
var d4 = d3/(1000*60*60*24);
var d5 = Math.round(d4);
sbm.util.setValue('tolerencedays',d5)
Note: i use a WebApplication so don't think i can use the jst. syntax?!
Is there also a date without the time available?
Thanks,
Danny
Yes. date dataslot is of two types,
1. Date and Time.
2. Date Only.
This date configuration can be selected in BPM Studio> Application> Dataslots tab>> double click> Default Format tab>Type.
In case if you face any issues, please send me your test application and i will modify it as per your requirement.
Thank you,
Parshuram.
Thanks Parshuram,
The date is now without Time.
But still got the problem with de sum between the 2 dates in my webapplication.
Thnx,
Danny
Please try below code,
var t1 = new Date(document.form.d1.value);
var t2 = new Date(document.form.d2.value);
alert(t2.getTime());
var t3 = t1-t2;
var t4 = t3/(1000*60*60*24);
var t5 = Math.round(t4);
sbm.util.setValue('textField1',t5);
d1 and d2 are date dataslot names. Please find attached sample application and let me know it helps.