titanium76 Posted December 20, 2007 Posted December 20, 2007 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?
Lee Smith Posted December 20, 2007 Posted December 20, 2007 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
titanium76 Posted December 21, 2007 Author Posted December 21, 2007 I understand it will fail. That is my point. Can I catch the error w/ something?
comment Posted December 21, 2007 Posted December 21, 2007 (edited) 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, 2007 by Guest
LaRetta Posted December 21, 2007 Posted December 21, 2007 (edited) 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, 2007 by Guest
titanium76 Posted December 21, 2007 Author Posted December 21, 2007 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?
LaRetta Posted December 21, 2007 Posted December 21, 2007 (edited) Last Monday can't be entered into a date field. It would help to provide specific, real examples. Edited December 21, 2007 by Guest
comment Posted December 21, 2007 Posted December 21, 2007 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.
Vaughan Posted December 21, 2007 Posted December 21, 2007 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..."
comment Posted December 21, 2007 Posted December 21, 2007 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.
Recommended Posts
This topic is 6243 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 accountSign in
Already have an account? Sign in here.
Sign In Now