Number of days between two days using FormCalc

Avatar

Avatar
Level 2
_jadobe_
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
_jadobe_
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
_jadobe_
Level 2

10-02-2009

Hi All,

Is there anyway to get the number of days between two days using formcalc.



Thankd

JJ

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

10-02-2009

By days I assume you mean dates. You will need to transform the date into a number of milliseconds from an epoch. In FormCalc this is done using the Date2Num funnction. Once you convert both dates then you can subtract one from the other to get a difference then change it from milliseconds to whatever units you want.



This can be done in Javascript but it is more difficult.

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

10-02-2009

I came across a sample where I did this before. Remember that this is FormCalc. The function returns the number of days since the epoch not the number of milliseconds (thats what Javascript does). Here is the command I used:



xfa.host.messageBox(Date2Num(EndDate.rawValue, "YYYY-MM-DD") - Date2Num(StartDate.rawValue, "YYYY-MM-DD"))