Jump to content

Welcome the ORIGINAL FileMaker Community

Take a moment to join us, no noise, all FileMaker...We Promise

RichGags

Custom Function help please

Recommended Posts

RichGags

Hey all!  I am trying to write a custom function to replace and/or substitute several items at once and I am having trouble with the syntax.

I need to take this input "Monday February 4 2019" and convert it to "2/4/2019". 

Basically I need to disregard the days of the week, replace the month text with the month number, and convert the spaces to slashes/

Any help would be greatly appreciated!    Thanks so much.

Share this post


Link to post
Share on other sites
MrWatson

Hi, you don’t need a custom function for that ... you can do it with a simple substitute function:

 

Substitute ( $dateSting ;

[“Monday ” ; “”] ;

[“Tuesday ” ; “”] ;

...etc. ...

[“January” ; 1 ] ;

[“February” ; 2 ] ;

... etc. ...

[“ “ ; “/“]

)

 

For good measure you might want to add multiple 

 

[“  “ ; “ “ ] ;

To convert multiple spaces to single spaces and finally wrap it all in a trim function. 

🙂

  • Like 1

Share this post


Link to post
Share on other sites
MrWatson

Just noticed we’re in the fm 11 room ..... If fm 11 doesn’t support the [] syntax, just use nested Substitute ( Substitute ( .... ; m ; “”) ; t ; “”) functions.

  • Like 1

Share this post


Link to post
Share on other sites
MrWatson

For convenience you can of course put this monster in a CF, ConvertDateString ( pDateString ) to make it easier to use. 

  • Like 1

Share this post


Link to post
Share on other sites
RichGags

Awesome!  Worked perfectly - thanks a million!

  • Like 1

Share this post


Link to post
Share on other sites

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

×

Important Information

Terms of Use