onnotche Posted April 4, 2005 Share Posted April 4, 2005 Hi, I would like Filemaker to halt a script if a given date is invalid. I've tried this If Date=10/10/2005 Message (sorry this date is invalid) Halt script End if Knowing how FM handles dates, I can understand that this does not work. But even if I try DateToText it does not work. What am I doing wrong? Link to comment Share on other sites More sharing options...
Maarten Witberg Posted April 4, 2005 Share Posted April 4, 2005 Is the date user entered? what version of fmpro? Are you sure the test is performed on the correct record, or is Date a global? kjoe Link to comment Share on other sites More sharing options...
onnotche Posted April 4, 2005 Author Share Posted April 4, 2005 Hi kjoe, thanks for your quick reply. I'm using FM5-5.5/server 5 The date is user entered and it is not a global. The script step that is supposed to validate the date entered by should include several invalid dates and date ranges. Link to comment Share on other sites More sharing options...
Maarten Witberg Posted April 4, 2005 Share Posted April 4, 2005 Do you plan on hardcoding these dates into the script? If I test against a datefield it works ok if[userDate=InvalidDate] message["invalid"] end if kjoe Link to comment Share on other sites More sharing options...
onnotche Posted April 4, 2005 Author Share Posted April 4, 2005 Well, I was actually thinking of hardcoding the dates in the script. Testing against datefields would oblige me to create a related file "invalid_dates.fp5", because there are several invalid dates every year. Link to comment Share on other sites More sharing options...
Maarten Witberg Posted April 4, 2005 Share Posted April 4, 2005 What if you use an InvalidDates field which is global- text, put the list of invalid dates in there, separated by paragraph marks, and then validate if[PatternCount(InvalidDates;DateToText(UserDate))>=1] ###etc end if You'd then just have to add to the InvalidDates field every year, instead of opening up the script every time. Mind you, it could be a little tedious if the ranges are long... You'd have to take care the format entered in UserDate (slashes or hyphens) is the same as the format in InvalidDates. hope it helps kjoe Link to comment Share on other sites More sharing options...
onnotche Posted April 4, 2005 Author Share Posted April 4, 2005 Just found out why date to text did not work: for testing, I used 05/05/2005, without realizing that DateToText returns 5/05/2005 instead of 05/05/2005. Thanks for your suggestion kjoe, i'll give it a try! Link to comment Share on other sites More sharing options...
Maarten Witberg Posted April 5, 2005 Share Posted April 5, 2005 I was wondering, are these invalid dates always the same, f.i. october 10 every year? Then you could validate using Month(UserDate)&Day(UserDate) and no more edits necessary kjoe Link to comment Share on other sites More sharing options...
onnotche Posted April 5, 2005 Author Share Posted April 5, 2005 Unfortunately not, actually the dates vary every year (Christmas, easter etc.). Thanks for your help, Onno Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.