Phillip Prahl Posted September 15, 2015 Share Posted September 15, 2015 Hi, I have the a calculation field running the following: ExecuteSQL ("SELECT MIN(checkins.date_due) FROM checkins WHERE checkins.id_contact=? AND checkins.isComplete=0"; ""; ""; id) If I tell the field that the calculation result is a number, then I appear to get the correct date back in the following format: YYYYMMDD, otherwise I get nothing or a ?. However using this result in a comparison with say get(CurrentDate) does not work. The strange thing is, that if I set the data formatting in the inspector to be 'general' i get YYYY-MM-DD, so it must know its a date somehow? Any help about how to get fop to recognize the sql result as a fmp date would be greatly appreciated! Link to comment Share on other sites More sharing options...
beverly Posted September 16, 2015 Share Posted September 16, 2015 Try this: STRVAL( MIN(checkins.date_due) ) or COALESCE ( MIN(checkins.date_due), '' ) These "convert" to FMP -date format of mm/dd/yyyy (or dd/mm/yyyy if non-US). Link to comment Share on other sites More sharing options...
beverly Posted September 16, 2015 Share Posted September 16, 2015 Sorry, "nested functions" (if one is an aggregate) do not seem to work well in eSQL. try this: Let ( [ $query = " SELECT MIN(checkins.date_due) FROM checkins WHERE checkins.id_contact=? AND checkins.isComplete=0" ; $result =ExecuteSQL ( $query ; "" ; "" ; id ) // returns yyyy-mm-dd ]; If ( $result ≠ "?" ; Let ( [ $y = Left($result; 4) ; $m = Middle($result; 6; 2) ; $d = Right($result; 2) ]; Date($m;$d;$y ) ) ; "?" )) 1 Link to comment Share on other sites More sharing options...
Phillip Prahl Posted September 17, 2015 Author Share Posted September 17, 2015 Thank you so much! I was also in the process of trying a workaround where I simply have another field that stores the date as an integer and then do my sql query with this field... Will try both solutions and see what happens Thanks again! Link to comment Share on other sites More sharing options...
Phillip Prahl Posted September 17, 2015 Author Share Posted September 17, 2015 Your suggested solution works great! Thanks for "let"ting me know 1 Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 3142 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