News, tips, advice, ideas, experience…

GetAsDate(x) ≠ GetAsDate( x & “”)

Ever had a trouble getting FileMaker Pro convert text to date reliably?

Last week I was helping my colleague to debug a solution that seemed to be swapping month/day values in some cases. When I checked the issue in detail I discovered a strange behavior in FileMaker's calculation engine. Although the file was set to "always use file's saved settings", GetAsDate was using the system settings when converting text returned from a plug-in.
 
The file was created with US date settings (month/day/year) while my system was set to Czech formats (day.month.year). Using GetAsDate on a text constant, even in a data viewer, was correctly using the US formats. However, when converting a (text for sure) value returned from 24U SimpleDialog Plug-In, the system format was used for some strange reason. What a big surprise it was for me when I tried to concatenate a space to the text value, and it was converted correctly, using the US formats...

 

 

Maybe a good reason to convert dates by hand rather than using GetAsDate...
Let(mdy = Substitute(the_text; ["/"; "¶"]; ["."; "¶"]); Date(GetValue(mdy; 1); GetValue(mdy; 2); GetValue(mdy; 3))
 
HTH  

By completing and sending the form you agree that 24U s.r.o., a company established under the laws of the Czech Republic, with its registered office: Zvole u Prahy, Skochovická 88, CZ-25245, registered in the Commercial Register with the Municipal Court in Prague, section C, inset 74920 will use your personal data contained in the form for the purpose of sending 24U’s news, updates and other commercial communications. Providing 24U with personal data for the said purpose is optional. Details on personal data processing and on your rights connected therewith are contained in 24U’s Privacy Policy.