Jump to content
Server Maintenance This Week. ×

possible to choose date format display on the fly?


human

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

Recommended Posts

I have a "purchase date" field on a layout. I know I can set the format to "as entered", "12/28/14", "Dec. 25, 2014" etc. But I would like to let the user choose the format, say from a pop-down list. I suppose I could stack a bunch of differently formatted fields on top of each other, and hide all but the one format the user chooses. But is there a simpler way?

Link to comment
Share on other sites

Not sure if it's simpler, but you could use a calculation field (with result type set to Text) that would convert the given date to the selected format. If you intend to use the same format notation as Filemaker does, the calculation could be something along the lines of:

Substitute ( DateFormat ;
[ "Thursday" ; DayName ( Datefield ) ] ;
[ "Thu" ; Left ( DayName ( Datefield ) ; 3 ) ] ;
[ "25" ; Day( Datefield ) ] ;
[ "12" ; Month ( Datefield ) ] ;
[ "December" ; MonthName ( Datefield ) ] ;
[ "Dec" ; Left ( MonthName ( Datefield ) ; 3 ) ] ;
[ "20" ; Left ( Year ( Datefield ) ; 2 ) ] ;
[ "14" ; Right ( Year ( Datefield ) ; 2 ) ] 
)

(This needs more work to allow leading zeros for day and month.)

Do note that no matter which option you choose, the formatting affects the display only. Users still need to enter dates in the date format used by the file.

 

Link to comment
Share on other sites

I created a value list to choose some different display options and overlaid them with hide calculations, and it works OK. However, even though FM can display a date like Dec 14, 2020, you cannot enter it that way - must be digits with separators. (Interesting - FM doesn't care what separator you use between digits and will accept dots, slashes, $ character, whatever). So I guess it would be confusing to users to display a date like Dec. or December but not allow that as input - of course I could write some functions to parse a text field, but that's overkill for this solution. When the field is set to display "As entered", and you use the pop down calendar to enter it, it has the format 12/25/2020, which in my case is the same as "short system date". So I guess i will set it to display that, just to be consistent.

Thanks.

Link to comment
Share on other sites

12 minutes ago, human said:

FM doesn't care what separator you use between digits and will accept dots, slashes, $ character, whatever

I believe that if you want to enter only the day and the month (or the month and the day, if your file is using a M/D/Y date format) and have Filemaker auto-complete the current year, you must separate them by either the separator used by the file's date format in use, or by a forward slash. Otherwise you can use any character as a separator except a letter, a colon or the plus sign.

Note also that the date format your file is using is not necessarily the same as your OS short date format - see:
https://help.claris.com/en/pro-help/content/different-system-formats.html?Highlight=use system format

 

 

Link to comment
Share on other sites

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