I'd like someone to be able to type 5, or 5pm, or 5 pm, or 5:30 pm
And how does the system know that 5 is for 5 pm and not 5 am?
If you are using FileMaker 11 or newer, set up the on object validate trigger to perform a script that corrects the formatting before Filemaker's data validation can kick in and complain that the format is not a valid time entry.
Right, that makes perfect sense. I should have been clearer:
I can't figure out how to actually write the auto-correcting script.
Actually, all of your examples except that lone 5 will be correctly accepted as the time for 5:00 pm (or 5:30 pm) in a time field. Only the case where you need a value of 5 to be entered and 5:00 pm to be the result is there a need for special handling as it would be interpretted as the time for 5:00 am.
Thus, you could just set up an auto-enter calculation if you need to automatically convert am times into pm values:
IF ( Self < GetAsTime ( "12:00 pm" ) ; self + 12 * 3600 ; self )
This expression adds 12 hours to any am times to change them into pm times 12 hours later.
(Be sure to clear the "do not replace existing values..." check box.)
ah but there's the problem. It was my understanding that yes, Filemaker would recognize all the examples as 5pm except the 5, which it would recognize as a duration of 5 hours. But whenever I enter a time in a field I get thrown this error. This is the underlying problem, I would like to accept the data the user enters, correct it (if possible) and then have it validated and commited, so that this error doesn't occur. Maybe I missed something in the field setup?
Partial solution discovered:
Removing the validation of "(Time of Day, Allow Override)" on the field allows it to accept 5pm, 5 pm, 5:00pm etc as times. Now I think it'll be easy to just add on a script that checks for an "m" at the end of the string and adds it if it isn't there to allow for the "5p" input eventuality (5p will through the same error even without the validation setting).
Is there any harm in removing the Validation setting from the field? It's set to be a time field, not text, so should be storing the data properly regardless. Any thoughts on if I might run into problems down the road?
I see no reason for the validation for a field of type time. If you enter an invalid entry such as "apple" in the field, FileMaker will still throw up an error message without that validation option.