Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Juggernaut

Controlling AM-PM suffix on time field

Featured Replies

I'm trying to write an application that captures start-stop times from data that is manually keyed into the database.

In order to calculate elapsed time, I need to be able to control how the AM-PM part of the time is appended.

FOR EXAMPLE:

Is there a way to key in the value 7:15, select AM or PM from a value list and end up with a timestamp result of 7:15AM?

My ultimate goal is to be able to subtract 7:15AM from 12:30PM to get the result 5.25 hours.

Any ideas?

Jarvis

The display fields don't have to equal the calc fields.

This said you can create two time calc fields that are 24 hour based. Just generate the value of the start and end times with a plus 12 hrs based on the selection of the 'pm' entries.

Now use a regular time calc field equal to stop - start and this gives you the elapsed time.

So the list of fields for less than 24 hour tasks is:

DISPLAY FIELDS:

TimeStartHR

TimeStartMIN

TimeEndHR

TimeStopMin

TimeStartAmPm

TimeEndAmPm

CALC FIELDS:

AmPmCalc =

Case

(TimeEndAmPm = (AM) and TimeStartAmPm (PM) ; 12 ;

TimeEndAmPm = (AM) and TimeStartAmPm (AM) ; 0 ;

TimeEndAmPm = (PM) and TimeStartAmPm (AM) ; 12 ;

TimeEndAmPm = (PM) and TimeStartAmPm (PM) ; 0 ;

0)

RealTimeStart =

(GetasText(TimeStartHR) & ":" & GetasText(TimeStartMIN)

RealTimeEnd =

(GetasText(TimeEndHR + AmPmCalc) & ":" & GetasText(TimeEndMIN)

RealElapsedTime =

RealTimeEnd - RealTimeStart

If you need to calc longer than this you need a day field for both entries and a test to calc that, more entries in the case statement, and then add to the RealTimeEnd.

Simple? Not.

Powerful? Yes

Just remember that the display logic and values don't have to be the same as the cacl fields.

Edited by Guest

3 Fields:

1) Time Field -- Time (entered as 7:15, 9:20 etc.)

2) Text Field -- Suffix (i.e. AM or PM)

3) Calc Field result time -- Calc being

Let(Tim = GetAsTime(TimeField) // The get as time isn't necessarily necessary -- though if you use a text field you'll have the same effect with this statement;

If(Suffix = "AM" ; TIM ; TIM + (12 * 3600) )

)

How about something simple (and works in both directions)?

timeEntry.fp7.zip

I must be missing somethhing here ... FM does all of this itself on time fields. A global text to type 7:15 and another global text to select AM or PM (or simply type it as well) - will produce 7:15 AM in a time field. Same with the ending time.

Then calculation (result is time) of End - Start will give you the overall time.

Your post wasn't there when I started, Michael. :)

Well since I did it, here's an example as well - how FileMaker knows the difference. You can just type AM/PM and it will keep track for you. I like Michael's idea ... but my vision of the request is a bit different so I'll attach my demo anyway.

Both methods are very simple because FM does all the work. In this example, I mixed putting the time and AM/PM in separate globals but typing all directly into time works as well ... it depends upon what your Users see and need.

Times.zip

Edited by Guest

  • Author

Thanks guys (& guy-etts)!

I will stare at your offerings and come to grips with this.

Jarvis

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.