This content has been marked as final. Show 9 replies
A sample of a FormCalc script:
var ReturnDate = "6 Jan 2008"
var FirstDay = "Jan 1, 2008"
Date2Num(ReturnDate, "D MMM YYYY") - Date2Num(FirstDay, "MMM D, YYYY")
You will heed to use the form field rather than a variable. I find that using the formattedValue and specifying the format string provides the most consistent result.
Thanks very much Geo for your help.
When I apply your script for the TotalDays field it give me the number 5.What about if the users the like to use other days..
How I can modify the script?
Instead of using the variable for date strings, you will need to use your fields' values and formats.
Hi Geo again. Sorry because I am taking from your time...
The fields FirstDay and ReturnDay are Date/Time Fields so the user
picks the desire date.
I am using the format DD-MM-YY.
what I am doing wrong and the script does not work?
Thanks Geo for your help very much
If you have the "Display Pattern" of "DD-MM-YY" for the fields, you should be using the "formattedValue" of the field with that format pattern.
Date2Num(ReturnDate.formattedValue, "DD-MM-YY") - Date2Num(FirstDay.formattedValue, "DD-MM-YY")
Thanks Geo, works prefect the only thing when I choose a date from a date/time field(FirstDay )in the TotalDays field first appears a 5 digits number and then when I pick a day from ReturnDate date/time field I have the right number of days.
Also the TotalDays(text field) shows the number o when you open the form.
There is any way to elaminate all these so the field Total is Blank?
Thanks for your patient in this matter.
You need to test for the availably of the data and if we have both dates compute the value else empty the field:
// if we have data
if(HasValue(ReturnDate) and HasValue(FirstDay) ) then
Date2Num(ReturnDate.formattedValue, "DD-MM-YY") - Date2Num(FirstDay.formattedValue, "DD-MM-YY") // compute the difference
null // force field to empty
THANKS for all your Help!
I am working on a similar problem. This too is my first time having to add specific scripting in order to get the exact information that is being requested. I have a date field (using calendar) that I need the time field (which is separate) to match. For example, if the date field is a Monday - Thursday the times can only be 7:30 am - 7:30 pm, however if the date if a Friday then the times can only be 8:30 am - 5 pm with no option of selecting Saturday or Sunday. Is this possible and if so can ANYONE help?? I've racked my brain on this.