Mohsin Khan
Posts: 0
Joined: Sat Mar 07, 2015 7:23 pm

problem in adding/substracting days/weeks to an input date

Hello,
Is there any function which can give a difference of the number of days or number of weeks in appery.io??

I am using this in the appery.oi server code to calculate the date +280 days from a particular date
Objective : making a service to be called on button click (To get a date as Input then
-adding 280 days to the input date and return the value in another field
-adding 10 weeks to the same input date and return in another field.

var now = new Date();
var value = new Date(input.getTime() + 24192000000);
// trying to add milliseconds in 280 days but is it possible to add number of days directly to the input date ?

// format as JSON and return the response
response.success(JSON.stringify({
result: value
}), "application/json");

PS:This is my first application and I am giving it a try to learn appery.io.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

problem in adding/substracting days/weeks to an input date

Hi -

There is no such function, you will need to do it with JavaScript, convert date to "Date" object and then you can use this Date object functions to get parts of date you need. For example separately get year, get day of week, get month etc. and make additions or subtractions.

You can read more about Date object here: http://www.w3schools.com/jsref/jsref_...

Mohsin Khan
Posts: 0
Joined: Sat Mar 07, 2015 7:23 pm

problem in adding/substracting days/weeks to an input date

Hello IIIya,
Thanks a lot for quick reply.
I have written this on a button click -- run java script function but how do I access the lable defined in Appery UI to fetch the result in that lable :

This is the button click code :

//To get the input date from datepicker
var input = Appery("mobiledatepicker_36").getAttr("defaultDateValue");

To get current Date,Month,Year
var d = new Date();
var l = d.getDate();
var m = d.getMonth() +1;
var n= d.getFullYear();

Can you please tell me how do I fetch the day month year from 'input' variable in Appery javascript window.

Can I use :
var i = input.getDate();
var j = input.getMonth() +1;
var k= input.getFullYear();
//Objective is to pass below mentioned string in a lable :
var ResultString = "Hello , Your Date is " + i + "-" +j + "-" + k ;

Also how to return this value (l+m+n OR i+j+k) to a lable or any text filed defined in Apperyio UI

my lable is with Name = ExpectedResult

Regards

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

problem in adding/substracting days/weeks to an input date

Hi Monsin,

Please try following JS code:

pre

//To get the input date from datepicker
var input = Appery("mobiledatepicker_36").getAttr("defaultDateValue");

var d = new Date(input);
var l = d.getDate();
var m = d.getMonth() +1;
var n= d.getFullYear();

alert("l = " + l);
alert("m = " + m);
alert("n = " + n);

/pre

Regards

Return to “Issues”