Help counting and calculating date differences in arrayed data

Help counting and calculating date differences in arrayed data

I have no experience scripting for arrays, indexed lists, etc. and need help to deluge-script the following business need:

I have an event_form, with a date_field, employee_field and time_field.

For any given date, the number of records logged by a employee varies from one date to another.

I also have a summary_form, with a date_field, employee_field, recordcount_field, and hours_field.

The script should accomplish something like this, diagramed in plain English:

For each date_field value and each employee value in the event_form
{
count number of records in each array;
calculate the difference in hours between newest and oldest time_field values in each array;
insert results for each array into a new record in summary_form;
}

The script will be scheduled to run either nightly or weekly.

Thank you!
Ricardo