Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adding a day to a date?

Elgen55
Level 2
Level 2

I am having trouble making a day add to a date, so far I can get the day to add to Jan. 1, 2000, what am I doing wrong with formcalc?

10 Replies
jasotastic81
Level 7
Level 7

Can you show what script you're using to add the day? I presume you're trying to add a day to a string that includes the date, already.

Elgen55
Level 2
Level 2

This is the one I have been trying.

 

var nDate = Date2Num(DateMade,"MM/DD/YY")

 

$=Num2Date(nDate + Cell4, "MM/DD/YY")

jasotastic81
Level 7
Level 7

Are you sure about the format that you're getting DateMade? I tried your code, and that was the way to make it fail and always give me whatever Cell4's value was added to 1/1/2000.

Trimmed to one line.

$ = Num2Date(Date2Num(DateMade,"MM/DD/YYYY")+Cell4,"MM/DD/YYYY")

Elgen55
Level 2
Level 2

I tried that formula and now it is going back to 1/1/1900 + number.  Should I make some kind of var to make it this year?

paulk07
Level 6
Level 6

How about this:

if (Cell4.rawValue==null) then

$.rawValue = ""

else

Num2Date(Date2Num(Cell4.formattedValue, DateFmt(2))  + 1, DateFmt(2))

endif

Elgen55
Level 2
Level 2

Thanks for the suggestion.

Ken Elgen

jasotastic81
Level 7
Level 7

Is Cell4 either a text field or a numeric field? Or is it something else?

Elgen55
Level 2
Level 2

It is a dropdown field but the user can change if needed.

Elgen55
Level 2
Level 2

Thanks for the suggestion, I really appreciate it.

jasotastic81
Level 7
Level 7

I'm not sure. I've set up something similar, and it is working. Are all of the values in the same subform? It might need more information to reference it. Do you have bindings set up for the dropdown?

adddaysformcalc.png