
1. Re: Seeking help to write a formula to subtract 15 minutes from a time field
try67 Nov 5, 2015 3:20 PM (in response to paula99520745)[Question moved to the Acrobat JavaScript forum]

2. Re: Seeking help to write a formula to subtract 15 minutes from a time field
try67 Nov 5, 2015 3:21 PM (in response to paula99520745)What's the format of the fields involved?
And there are no date/time pickers in Acrobat forms (although some thirdparties have developed various date pickers).

3. Re: Seeking help to write a formula to subtract 15 minutes from a time field
paula99520745 Nov 9, 2015 7:45 PM (in response to try67)Hi There
I have tried the fields as Time 10:30 but my form kept complaining the over the input field as people tended to try and put 10:30am in as 10.30.
I am currently using Number which calculates but gives funny solutions, like subtracting 15 minutes off 10.00 equal 9.75 and of course I want to see 9:45
I am already successfully using a date picker to choose meeting date etc I was hoping someone had developed a time picker too..
Paul

4. Re: Seeking help to write a formula to subtract 15 minutes from a time field
try67 Nov 10, 2015 1:15 AM (in response to paula99520745)You can use dropdowns with values from 112, 059 and AM/PM...

5. Re: Seeking help to write a formula to subtract 15 minutes from a time field
paula99520745 Nov 10, 2015 6:57 PM (in response to try67)Good idea
I have my fields & dropdown formatted as a Number
Like 8.00 and 8.45
When I select 8.00 the field picking up the data calculates
MTStart0.15
The result shown is 7.85
I want it to say 7.45
Any help appreciated

6. Re: Seeking help to write a formula to subtract 15 minutes from a time field
gkaiseril Nov 11, 2015 11:14 AM (in response to paula99520745)Then one needs to convert the decimal hours to hours and minutes. There are 60 minutes to an hour so one needs to multiply the decimal portion of the result by 60. The format for the result should be h:MM. The "." separator denotes a decimal value, while the ":" denotes separation of hours and minutes.
You also need to use the decimal values for the minutes if you are going to use the raw values for the computation or convert the inputted values of hours and minutes converted to minutes, then subtracting 15 minutes, and then convert the total minutes into the hours:minutes format.
You should also consider how to handle times from 12:00 am and 12:14 amp since the result of these calculations would be a time in the previous day.
A possible script without the meridian:
// get hours and minutes;
var nHrs = 10; // 10:00 am
var nMins = 0;
app.alert("Input time: " + util.printf("%,101.0f", nHrs) + ":" + util.printf("%,102.0f", nMins), 3, 0);
// convert imputted hours and minutes into total minutes;
var nTotalMins = (nHrs * 60) + nMins
// subtract 15 minutes from total minutes;
nTotalMins = 15;
// format total minutes back to hours:mintues;
// get whole hours from total minutes;
var nEndHrs = Math.floor(nTotalMins / 60);
// get remander minutes from total minutes;
var nEndMins = nTotalMins % 60;
// create display stirng;
var cEndTime = util.printf("%,1 1.0f:%,102.0f", nEndHrs, nEndMins);
app.alert("Start tme less 15 min is " + cEndTime, 3, 0); 
7. Re: Seeking help to write a formula to subtract 15 minutes from a time field
paula99520745 Nov 11, 2015 2:58 PM (in response to gkaiseril)Thanks for the information..
I am a total noob at this so although I can see how the code sample works I have no understanding of how to pickup my data and modify the formula
I am using a drop down field called MTStart where uses select a time, eg 10.00 I am using another hidden field to pick up that choice and deduct 15 minutes from their choice
Checking all my fields they conform to your suggestions but pasting the code as supplied doesn't return any result or error.
Any support appreciated

8. Re: Seeking help to write a formula to subtract 15 minutes from a time field
paula99520745 Nov 12, 2015 8:00 PM (in response to paula99520745)Found an easier way to handle..
Used a dropdown box with setting the Options TAB value set to Export a value 15 minutes before selected time.
So the client can see and select 10:00 the exported value is set to 9:45
I then picked up that value in a new text field and could use that