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

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

Recommended Posts

Posted

Hi,

I have no idea where to put this post, so I'll put it here...

Does anyone know how to differentiate between English US and English UK date formatting, in a script or field calculation confused.gif.

Get( SystemLanguage ) just returns "English". Also, you don't appear to be able to set a field to (say) GetAsDate( "31/01/2005" ) and then retrieve it as "?" - the script interpreter always interprets it as 31st January.

Any ideas ?

Thanks,

Roger.

Posted

Filemaker uses system date formatting for display, to interpret data entry, and in the GetAsDate (text) and GetAsText (date) functions. System date formatting can be set independently of the language, so Get(SystemLanguage) cannot be relied upon to determine the current system date format.

If your system is set to use the d/m/y format, GetAsDate ( "31/01/2005" ) is a valid date entry. If you change your system to m/d/y, AND set the file to use current system settings, it will become invalid and return "?".

I tend to not rely on date formatting for anything critical, and use date functions instead to point at month and day explicitly.

You could determine the current system date format by examining the interpretation of a known date, although it will take some work. For example:

Let (

test = GetAsText ( Date ( 1 ; 2 ; 3456 ) ) ;

Case (

Left ( test ; 1 ) = 0 ;

// there is a leading zero for the first parameter

Left ( test ; 1 ) = 1 ;

// the first parameter is month with no leading zero

Left ( test ; 1 ) = 2 ;

// the first parameter is day with no leading zero

etc.

You can continue this to determine the rest of the formatting, incl. the separator and year's length.

Posted

I thought a trivial mod to my date fields would be to have a default value (when the record is created) of "mm/dd/yyyy" (or "dd/mm/yyyy").

Turns out not to be trivial at all.

I tried using:

Left( GetAsText( Date( 1; 11; 2001 ) ) )

but it ALWAYS returns "11" in the first two characters irrespective of the current system format (presumably coz the file was created on a UK setting).

However, all the date fields show the date correctly when I switch system formats (they show up as either mm/dd or dd/mm).

Regards,

Baffled and Frustrated. mad.gifconfused.gifcrazy.gif

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