Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Validating dates rather pointless

Featured Replies

I'm currently working on a complex validation of data-types. Since the input is text (coming thru JSON over the net) I have to make formal checks first, all of the following are considered valid dates:

"14/11/2004"

"11/14/2004"

"2004-11-14"

I thought I could rely on the FMP engine and let it check if this day actually existed and was rather shocked when I debugged my findings:

IsValid ( Date ( 11 ; 14 ; 2004 )) => 1

IsValid ( Date ( 2 ; 30 ; 2003 )) => 1 (there is no 30th of February)

IsValid ( Date ( 99 ; 99 ; 1999 )) => 1 (Maya calendar?-)

The last entry is absurd.

Date ( 99 ; 99 ; 1999 ) => 07/06/2007

When I try to input "99/99/1999" into a date field FMP complains like in GetAsDate ( "99/99/1999" ).

But how am I supposed to check all the differently formated dates since GetAsDate ( "2004-11-14" ) is invalid as well?

I found a workaround but wondered if this behaviour was intended.

Thanks for any feedback.

TSW.

I am afraid you are missing an important purpose of the Date() function: to calculate a date out of the given elements. The result of Date ( 2 ; 30 ; 2003 ) is the (valid) date of March 3, 2003. There is indeed no 30th of February, so the Date() function calculates the date that is 30 days later than February 1. This is what gives the Date() function its real power.

To check that a text string represents a valid date, try =

IsValid ( GetAsDate ( YourTextDate ) )




Note that the result depends on the date format being used by the file:




IsValid ( GetAsdate ( "2/28/2003") )

will return true if the file uses m/d/y date format, false otherwise.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.