Thanks problem solved. I edited the moodle code in get_logs to print out the arguments so i could see how the $select string worked. I suspected it was either the select or where part of the sql query.
In case this helps anyone later $select should look like this:
l.userid = '1' AND l.time > '1097449200' AND l.time < '1097535600'
I figured out the strings i needed by editing the get_logs method in datalib.php to print the arguments it was passed and then using the logs page, and inspecting the strings it was generating.
Thanks
JK