Jump to content
Server Maintenance This Week. ×

Quick Time Entry Function


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

Recommended Posts

I found a nice custom function in the comments of this CF  That allows a user to quickly enter times.

 

Let(
[
tt =
Int(
Substitute(
Choose( Length( textfield ) - 1; "ç00"; "ç00"; "ç"; "ç" );
"ç";
textfield
)
);
ts = Case( Div( tt - 100; 1200 ); 100 + Mod( tt - 100; 1200 ); tt )
];
Replace( ts; Length( ts ) - 1; 0; ":" ) & " " &
Case(
Position( Lower( textfield ); "p"; 1; 1 );
"P";
Div( tt - 100; 1200 );
"P";
"A"
) & "M"
)
But there are a few bugs:
00 = 12:00pm
10p and up = 12:00pm
 
Plus I would like a tweak:
let "." convert to 'pm'  (for users with extended keyboards)
 
any ideas?
Link to comment
Share on other sites

spoken like a true father David.

 

Okay it could be streamlined. But I fixed the 10p–12am entries, default is PM and a '.' (period) equal AM

 

 

Let([

start = Lower ( textfield ) ;
value = Filter ( start ; "1234567890" ) ;

tt =
Int(
Substitute(
Choose( Length( value ) - 1; "ç00"; "ç00"; "ç"; "ç" );
"ç";textfield)  );

ts = Case( 
Div( tt - 100; 1200 ); 100 + Mod( tt - 100; 1200 ); tt ) ;

tc = Replace( ts; Length( ts ) - 1; 0; ":" ) ;
dv = Abs (Div( tt - 100; 1200 )-1)
];


tc & " " &
Case(
Position( start; "a"; 1; 1 ) or Position( start; "."; 1; 1 ) ; "A";
dv =1; "P";dv =2; "A"; dv =0; "A"; 
"P" ) & 
"M"

)
Link to comment
Share on other sites

This topic is 4031 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.