Enter Date press calculate then display the date 14 days from original date entered?

Hi,

I was wondering if there is a formula i can use to work out what the date would be if i added on 14 days

For example.

(sorry for Australian formatting)

i enter a date of 14/03/2017 then i press a calculate button then it would work out what that date would be and in that case it would show as the 28/03/2017

I will need this formula to work across different months, years and also work in leap years etc.

Thanks in advance,

Cheers
Chris

Hi

you can simply use javascript and embedd this on buttonclick and set a variable to store the new date.

a library is for example Moment.js | Home and the method moment().add(14, ‘days’).calendar();

I hope this helps.

the quality of the result is related to the entered data. if a valid date has been entered you can calculate with the dateobject in axure e.g. .addDays() and request the result as .localDateString() or .dayOfTheWeek() or whatever.

the date-object automatically calculates correct dates across month, years and leap years.

in this special case, because my name is gregor and it is my calendar, i can mention that even the secular year exception of 2100 will be covered by the date object calculations (and the exception of the excption of the exception in 2000 was covered too).
Untitled.rp (57.7 KB)

Thank you for your replies,

@knobiwu - i’m not quite sure how to use the JavaScript efficiently

@Gregor - thanks for the file but i keep getting invalid date using your .rp file


Hi!

Axure’s date function assumes mm/dd/yyyy order no matter what your OS’s region is.

The below parses each segment of the dd/mm/yyyy date string to extract day, month, and year (whether or not leading zeros exist) and applies the math and puts everything back in dd/mm/yyyy order.

Live sample

File: dd-mm-yyyy-math.rp (59.4 KB)

1 Like

Ok thanks, that helps heaps, that does work…

i noticed that i have to keep it as "text field type - text " rather than use “text field type - date” option so i can’t use the calendar that populates in chrome?

Assume there is no way around that?

on another note, not sure if i should post a new topic or not, but is there an easy way to populate today’s date in a text box on page load? (using DD/MM/YYYY)

[[LVAR.substr(3,2)]]/[[LVAR.substr(0,2)]]/[[LVAR.substr(6,4)]]

if the month or the day is entered with one digit or the year with 2 it will break again.
you could split the string by / there was a thread… here it is.
using this you can build something stable… but i would not call it an easy way.

perhaps alyssas request will provide a nicer solution soon.

HI Joseph I think I need this but I cant open the 8.0 rp file as im on 7.0.
Please can you paste the script?

I recreated this in RP 7 in his other thread here:

1 Like