I have 3 fields. "Project Type", "Calculated Time" and "Due Date". The "Calculated Time" field is hidden from view ("Show This Field = Never") and set to default to a number that is based on what the user selects in the drop down field named "Project Type". Here is what I've used there:

=ProjectType = "Flyer: Up to 30 Products" ? "7" : ProjectType = "Flyer: Up to 60 Products" ? "12" : ProjectType = "Flyer: 60+ Products" ? "18" : "7"

I would like the "Due Date" field to show a default date based on today's date PLUS the number of days calculated above. (IE: If today is 5/20/15 and i've selected "Flyer: Up to 30 Products" it should add 7 days and the default value would then be 5/27/15. I tried something like below and got the error "No applicable method 'AddDays' exists in type 'DateTime' at character 15"


Can someone please help as to why I cannot call upon the "CalculatedTime" field using this method. When I replace CalculatedTime with a number it works fine.

Additional screenshots here:

enter image description here

enter image description here

1 Answer 1


I am a developer for Cognito Forms.

You are very close to getting the calculation to work, AddDays takes an integer value and the value and what you were generating is a decimal value. You will need to add a little extra code to your Due Date calculation to get it running correctly.


One other change I would make to your calculation in the CalculatedTime field would be to remove the quotation marks (") from around the numebrs, so your calculation looks like this:

=ProjectType = "Flyer: Up to 30 Products" ? 7 : ProjectType = "Flyer: Up to 60 Products" ? 12 : ProjectType = "Flyer: 60+ Products" ? 18 : 7
  • Thanks Nicholas, very much for the response! I've added the Int32 command to convert the CalculatedTime value to an integer, however I am now receiving an error that says "A value of type 'String' cannot be converted to type 'Int32' at character 23." ALSO would you mind clarifying why remove the quotes from the number values in CalculatedTIme field?
    – Wil
    May 21, 2015 at 15:40
  • You will need to be sure that the Calculation field's type is set to "Number" If type is set to any other type then it would be expecting a 'String' rather then a number. The numbers in the CalculatedTime do not need to be in quotes because we are looking for numbers and by putting them into quotes we are turning them into a string value. If you need more help or have other questions feel free to submit a Bug Report (cognitoforms.com/bugreport) and we can help you further via the Support System.
    – Nicholas
    May 21, 2015 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.