Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7034 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I have a script that generates a time based on a calculation. Could someone tell me how to have the script convert it to the format A.M./P.M. instead of the 24 hour format that it is ending up in.

(currently it's resulting in 14:30:00 instead of 2:30 P.M. which is what I would prefer)

Edited by Guest
Posted

That's how FM stores time. You'll need to change how the time is displayed by clicking on the Time Format options on the context menu (or whatever its called on a Mac).

Steve

Posted

I'm not concerned with how the date looks on the layout. I know I can change the format of the field on the layout. B)-) The thing is, I want to use that field in an email that goes out, and I want the time of the pulled value to be in AM/PM format, not in 24 hour time.

Perhaps if I write a function that finds the hour of the time and if it's over 12 , give back hour-12 , concatenate it with minutes, and if it's over 12 , stick a PM onto it... hmmm... maybe I can do this.. seems pretty complicated... I thought there was an easier way... but maybe not.. I guess I'll at least try this.

If anyone has any input, I'd love to hear it!! :)-)

Posted

Yipeeee B)-) I think I did it !! :)-)

---------

Case (

Minute(time) > 10;

Case(

Hour ( time ) = 24;

(Hour (time)-12) &":"& Minute(time) & " AM";

Hour ( time ) = 12;

(Hour (time)) &":"& Minute(time) & " PM";

Hour ( time ) > 12;

(Hour (time) - 12) &":"& Minute(time) & " PM";

Hour ( time ) = 0;

(Hour (time) + 12 ) &":"& Minute(time) & " AM";

Hour ( time ) < 12;

(Hour (time) ) &":"& Minute(time) & " AM");

Minute(time) < 10;

Case(

Hour ( time ) = 24;

(Hour (time)-12) &":0"& Minute(time) & " AM";

Hour ( time ) = 12;

(Hour (time)) &":0"& Minute(time) & " PM";

Hour ( time ) > 12;

(Hour (time) - 12) &":0"& Minute(time) & " PM";

Hour ( time ) = 0;

(Hour (time) + 12 ) &":0"& Minute(time) & " AM";

Hour ( time ) < 12;

(Hour (time) ) &":0"& Minute(time) & " AM") )

-------

Posted

Um...

Any chance someone can explain what this funky calculation is doing !? B)-)

(and also,.... how it is doing it ?)

--

Hour ( theTime ) - 12 * ( theTime >= 13*3600 ) & ":" &

Right ( "00" & Minute ( theTime ) ; 2 ) &

Choose ( theTime >= 12*3600 ; " AM" ; " PM" )

Posted

If theTime is greater than or equal to 46800 (the numerical equivalent of 13:00:00 or 1 PM), then the test in parentheses returns a 1 and 12 is subtracted from the hour. A leading zero is then added to the minute if it is less than 10. (Note that Right( "0" & Minute(theTime); 2 ) would work also). Then, PM is added if theTime is greater than or equal to 43200 (12 PM); otherwise AM is added.

Does that help?

Posted

Well the point is that one day is 86400 seconds. But since 12 AM is noon, will the switch be after 12:59 which is 13*3600 seconds since the beginning of the day. The stuff in just after 12* is either 0 or 1, while Hour( gives the time in 24 hours.

Next part needs to take care of what is called leading zeros, for the first 9 minutes of each hour.

The larst part carries some of the logic of the first third, it could have been a Case( or If( instead, but Choose( is believed to be a tad faster than Case( or If(

--sd

This topic is 7034 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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