Jump to content

This topic is 3431 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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!

 

Posted

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).

 

 

Posted

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 ) 
            )
            
        ; "?" )

  • Like 1
Posted

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!

This topic is 3431 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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