Expand my Community achievements bar.

Adding a day to a date?

Avatar

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

Avatar

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.

Avatar

Level 2

This is the one I have been trying.

 

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

 

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

Avatar

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")

Avatar

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?

Avatar

Level 6

How about this:

if (Cell4.rawValue==null) then

$.rawValue = ""

else

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

endif

Avatar

Level 2

Thanks for the suggestion.

Ken Elgen

Avatar

Level 7

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

Avatar

Level 2

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

Avatar

Level 2

Thanks for the suggestion, I really appreciate it.

Avatar

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