You will need to learn about RELATIONSHIPS.
Have a look in your template database at the Relationships Tab when you are in File>Manage>Database. This is where relationships between Tables are set up.
To look from a parent to a child table via a relationship a PORTAL is used.
One table may be related to another in many different ways eg. Paid Invoices or Overdue Invoices. Each time you want to have a new way of relating an 'Instance' of the table is placed on the Relationships tab.
There has been much written about relationships and there are some very good resources here at TechNet in the Developer Resource Center.... in the tabs at the top. There are also good sections in the Documentation you installed with FIleMaker.
Dates can be calculated and dates can be used in calculations. When you subtract one date from another you get a number... of days. When you subtract Time from another you get a time that is the difference in the 24hr time... which can then be calculated as fractions for use in other calculation.
One of the best ways to figure out how those things have been done is to look at the way it was put together in the template... as you have done. If you have FileMaker Pro Advanced you can use the Script Debugger and Data Viewer Tools to help you understand the scripts and buttons and layouts and relationships... and many things you are yet to find out about.... all work together. Essentially you can follow the trail... eg. Button X runs script 1. Script 1 goes to a layout, finds records, sorts the records, runs script 2 then goes to the original layout. Script 2 Prints the pages of the report.
I hope this helps.