There is a function in lib.php called "facetoface_get_session_dates" with a parameter of $sessionid. Use this instead of making a database call