December 20, 200718 yr Ok, if I do this calc in a calc field and result text: Date("NonDateText") I get a result of "?" so, is there a way to capture this error and with a case statement offer an alternative answer?
December 20, 200718 yr FileMaker will only accept Dates in Date Fields, and if you want to convert text to a date, then you will need to use one of the Date Functions depending on how the text is. What does the text look like? Lee
December 21, 200718 yr Author I understand it will fail. That is my point. Can I catch the error w/ something?
December 21, 200718 yr Can you explain where you will be using this, and what for? Without it, the question is too wide (i.e. too many possible answers). BTW, Date ("string") will always return an error, no matter what the string is. Edited December 21, 200718 yr by Guest
December 21, 200718 yr Possibly an IsValid ( ) ? It would return 1 (boolean true) if it was a date field but the date was not recognizable by FM, ie, IsValid(textDate) Yes. We can't know without more information but I got the better of myself ... : Edited December 21, 200718 yr by Guest
December 21, 200718 yr Author Can you explain where you will be using this, and what for? Without it, the question is too wide (i.e. too many possible answers). BTW, Date ("string") will always return an error, no matter what the string is. I know that Date ("string") will always return an error... let's pretend that a user entered "Last Monday" instead of 1/2/2000.... is there and error capture where i can allow errors to result as the text they were entered as?
December 21, 200718 yr Last Monday can't be entered into a date field. It would help to provide specific, real examples. Edited December 21, 200718 yr by Guest
December 21, 200718 yr A user entered "Last Monday" instead of 1/2/2000 where? Let's NOT pretend, and have a clear picture of the situation instead. Date ("1/2/2000") will also return an error, so I don't see how that's relevant.
December 21, 200718 yr Calculations don't return error codes, so you're on the wrong path right from the outset. Only script steps return error codes. The "?" is the closest thing you'll get to a calculation returning an error. (In fact that what it's returned for.) LaRetta's suggestion of using IsValid() is a good one. That's exactly what the function has been created for. You might have some luck with GetAsDate( Text ) but the success will depend on the OS date format (dd/mm/yyyy or mm/dd/yyyy) and the consistency of the data entry. Otherwise you're going to have to parse the entered text, try to guess it's meaning and process it accordingly. It's not a trivial job. Much frustration is caused by original posters trying to "generalise" their questions: subsequent posters spend time and effort answering the question posted only to be told "that's not really the case..."
December 21, 200718 yr Calculations don't return error codes They can, if you want. For example, EvaluationError ( Evaluate ( "Date ("1/2/2000")" ) ) will return 1201 ('Too few parameters in the function'). But it requires repeating the entire formula as text, which may not be convenient in most circumstances.
Create an account or sign in to comment