There are multiple ways to set this up. Assuming that Time is a field of type Time, you might use a case function like this:
06.:00 and 12:00
12:01 and 14:00
14:01 and 22:00
22:01 and 05:59
Case ( Time < GetAsTime ( "6:00" ) ; "Bedtime" ;
Time < GetAsTime ( "12:01" ) ; "Breakfast" ;
Time < GetAsTime ( "14:01" ) ; "Lunch";
Time < GetAsTime ("22:01" ) ; "Dinner";
The above calculation works with out checking both lower and upper limits because case functions evaluate from top to bottom and go with the first expression that's True.
Note that it's also possible to also set up a table of text and time values and "look up" such a result as well. The "look up" method allows users to modify the parameters of what text is returned for what time values without having to ask you as the developer to redefine the calculation.
I get the message that you can see in the attached clip about an Operator is required here and it highlights time which is my field name
Thanks as ever
At the end of the first line of the calculation, you are missing a semi-colon after "Bedtime".
I have created the suggested script it read as follows
Case ( for filemaker set up excel Converted::Time < GetAsTime ( "06:00:00" ) ; "Bedtime" ;
for filemaker set up excel Converted::Time < GetAsTime ( "12:01:00" ) ; "Breakfast" ;
for filemaker set up excel Converted::Time < GetAsTime ( "14:01:00" ) ; "Lunch";
for filemaker set up excel Converted::Time < GetAsTime ("22:01:00" ) ; "Dinner";
I have set a button on a field call Meal to perform this script but nothing happens.
All help gratefully received
This is not a script, but a calculation. It can't just be "performed" by a button click as it would have to be set up as part of a script step/button option that uses the calculation. You'll need to either set this up as the calculation for a calculation field or a text field with an auto-enter calculation or fix whatever error was made setting this up with your button.
If you want to fix the button setup, please share the exact details of how you set this up.
perfect - all I had to do was change the field to a Calculation field and paste the formula back into it.
It works a treat, my diabetes nurse will be very impressed as I can now record my levels and my food in one place and import my data from my glucose monitor