Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Calculate Date
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Calculate Date

 Post Reply Post Reply
Author
Kickinho View Drop Down
New Member
New Member


Joined: 11 Jul 2014
Points: 2
Post Options Post Options   Quote Kickinho Quote  Post ReplyReply Direct Link To This Post Topic: Calculate Date
    Posted: 11 Jul 2014 at 7:00am
Hello,

i'm trying to realize a PDF Form which calculates several dates.
In this form is a table which has a column called "Date".

Now I want to write a date (01.01.2014) in this cell and all following cells should add one day and write it in the cells.

For Example:

Field 1: 01.01.2014 --> This Date should be added by the User
Field 2: 02.01.2014 --> The Date should be calculated (Field 1 + 1 Day)
Field 3: 03.01.2014 --> (Field 1 + 2 Days)
Field 4: 04.01.2014 --> (Field 1 + 3 Days)

I hope that you can help me?

Best regards,
Matthias Paus

Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4116
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2014 at 8:26pm

What code have you tired?

Do you understand how a circular calculation works for dates?
 
One can just not increment the day by 1 since the counter rolls back over to 1 when the date reaches 28, 29, 30, or 31 depending upon the month and year.
 
I would use the "util.scand()" method to convert the date string to the JavaScript date object. Then use the various properties and methods of the date object to increment the day and set the value of the various fields.
 
For January 31 try:
 
var cDate = "31.01.2014"
var oDate = util.scand("dd.mm.yyyy", cDate);
console.println("Today is " + util.printd("dd.mm.yyyy", oDate));
for(var i = 0; i < 4 - 1; i++) {
oDate.setDate(oDate.getDate() + 1);
console.println("in " + (i + 1) + " days the date will be " + util.printd("dd.mm.yyyy", oDate));
}
 
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4116
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2014 at 10:21pm
The results for the above code using 30.01.2014 is:

Today is 30.01.2014
in 1 days the date will be 31.01.2014
in 2 days the date will be 01.02.2014
in 3 days the date will be 02.02.2014
true
 
So you can clearly see the turnover of the date value.
Back to Top
Kickinho View Drop Down
New Member
New Member


Joined: 11 Jul 2014
Points: 2
Post Options Post Options   Quote Kickinho Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jul 2014 at 6:42am
Thank's for your Support.

I have absolutely any programming skills in JavaScript and that's my Problem.

For Example in VB i know how to configure such a loop, but not in JavaScript.

So, is it may be possible that you show me a code, which sould work?

The Users write a date in the Field "Date1".
And I'm searching for a method, that writes Date1 + one day in the fields "Date 2", "Date3", "Date4" and so on.

Thank's so much four your help!
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jul 2014 at 11:26am
Why not have a go at learning? You'll find you get much more support if you seem to be willing to try, while asking for a working code is likely to get really rather negative responses.
Back to Top
RaeEveMay View Drop Down
New Member
New Member
Avatar

Joined: 31 Jan 2012
Location: Big Bear Lake
Points: 7
Post Options Post Options   Quote RaeEveMay Quote  Post ReplyReply Direct Link To This Post Posted: 30 Oct 2014 at 10:33pm
I hope this helps:

var f = this.getField("start");
var d = new Date(f.value);

d.setDate(d.getDate() + 1);
event.value = util.printd("mm/dd/yy", d);
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4116
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 31 Oct 2014 at 4:03pm

Since there will be a new field for each date, you need to adjust the number of days being added by each field.

With a planned naming convention, the field name can be calculated within the control loop and the appropriate field could be updated by the number of days to add for that field.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.047 seconds.