---
source: https://carbone.io/examples/s-attendance-record/
title: "Employee Timesheet Template, Time and Attendance | Carbone"
description: "Generate monthly employee timesheets from your time clock or WFM data: daily punches, workweek overtime, exception codes and sign-off in a Word template."
generated_at: "2026-11-17"
---

# Time and attendance record

Monthly timesheet with punches, overtime, exceptions and approvals

[![Time and attendance record: PDF generated from a DOCX template and JSON data](/examples/s-attendance-record/thumb-result.webp)](/examples/s-attendance-record/result.pdf "Download the generated document")

[Download template](/examples/s-attendance-record/template.docx)

[Sample data](/examples/s-attendance-record/data.json)

[Download the generated PDF](/examples/s-attendance-record/result.pdf)

- **Template:** DOCX
- **Export as:** PDF, DOCX, ODT, HTML, PNG [+25 more](/documentation/developer/http-api/generate-reports.md#output-file-type)
- **Carbone:** 5.18+

Features

-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Nested loop](/documentation/design/repetitions/with-arrays.md)
-   [Horizontal loop](/documentation/design/repetitions/with-arrays.md)
-   [Array filter](/documentation/design/repetitions/filtering.md)
-   [Aggregation](/documentation/design/computation/aggregation.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Color](/documentation/design/advanced-features/colors.md)
-   [Date](/documentation/design/formatters/date.md)

## Generate timesheets from your time and attendance system

Time clocks, workforce management (WFM) platforms and payroll preparation tools close each period with a time and attendance record per employee. The employee attests the hours, the manager approves them, and payroll runs from the approved record. In the US, the Fair Labor Standards Act requires employers to keep the hours worked each workday and each workweek for nonexempt employees ([29 CFR 516.2](https://www.law.cornell.edu/cfr/text/29/516.2)), and overtime is due for hours worked above 40 in a workweek ([29 CFR 778.101](https://www.law.cornell.edu/cfr/text/29/778.101)).

In this example, a fictional distribution center prints the February record of a maintenance technician: punches rounded to the quarter hour, unpaid meal periods, overtime per workweek, paid leave and holidays kept out of the overtime count, and exception codes for late arrivals, early leaves and missed punches. Your system sends the punches to the Carbone API as JSON, and the Word template computes every total.

In this example, you will:

-   Repeat the days inside each workweek with a nested loop, and print a subtotal per workweek
-   Count days and sum hours with aggregators and array filters
-   Color the exception codes and a month calendar from the status of each day

## Time and attendance record example

### Template

The DOCX template is a Word document with Carbone tags. The key tags:

| Where | Tag |
| --- | --- |
| Day row | `{d.weeks[i].days[i].date:formatD('MMM D')}` `{d.weeks[i].days[i].in}` `{d.weeks[i].days[i].out}` |
| Hours of the day, blank when zero | `{d.weeks[i].days[i].worked:formatN(2):ifEQ('0.00'):show('')}` |
| Workweek subtotal | `{d.weeks[i].days[].worked:aggSum:formatN(2)}` |
| Days worked | `{d.weeks[].days[worked>0].date:aggCount}` |
| Late arrivals | `{d.weeks[].days[code='LATE'].date:aggCount}` |
| Total paid hours | `{d.weeks[].days[].worked:add(.leave):aggSum:formatN(2)}` |
| Calendar day | `{d.calendar[i].date:formatD(D)}` in a horizontal loop |

### JSON data

An excerpt; the data sample has the 21 days of the period.

```json
{
  "employee": { "name": "Marcus Whitfield", "id": "E-204817", "jobTitle": "Maintenance Technician II", "flsaStatus": "Nonexempt, hourly" },
  "period": { "start": "2026-02-01", "end": "2026-02-28", "workweek": "Sunday 12:00 AM to Saturday 11:59 PM" },
  "weeks": [
    {
      "start": "2026-02-01", "end": "2026-02-07",
      "days": [
        { "date": "2026-02-06", "schedIn": "7:00 AM", "schedOut": "3:30 PM", "scheduled": 8, "in": "6:57 AM", "out": "4:32 PM",
          "meal": 30, "worked": 9, "regular": 5.75, "overtime": 3.25, "leave": 0, "code": "", "status": "worked", "note": "Dock door 12 repair, approved" }
      ]
    }
  ],
  "calendar": [ { "date": "2026-02-01", "status": "off" }, { "date": "2026-02-02", "status": "worked" } ]
}
```

## How to build a time and attendance record

### 1\. Repeat the days inside each workweek

Overtime is counted per workweek, so the data groups the days by workweek. In the daily table, the day row repeats the days of the current week with a [nested loop](/documentation/design/repetitions/with-arrays.md#nested-arrays): `{d.weeks[i].days[i].date:formatD('MMM D')}`, `{d.weeks[i].days[i].in}`, `{d.weeks[i].days[i].out}`, and so on. The next row ends the day loop with `{d.weeks[i].days[i+1]}`.

Below it, the subtotal row prints `Workweek {d.weeks[i].start:formatD('MMM D')} to {d.weeks[i].end:formatD('MMM D')}` and sums the hours of the week with [:aggSum](/documentation/design/computation/aggregation.md#learn-with-aggsum-partitionby-aggregator-with-nested-arrays): `{d.weeks[i].days[].worked:aggSum:formatN(2)}`. A last row, `{d.weeks[i+1]}`, ends the week loop.

Quote a date pattern that contains a space or a comma: `formatD('MMM D, YYYY')`.

### 2\. Count days and sum hours with array filters

The KPI strip and the period total use [aggregators](/documentation/design/computation/aggregation.md) on all the days of all the weeks, reduced by [array filters](/documentation/design/repetitions/filtering.md):

```text
{d.weeks[].days[].worked:aggSum:formatN(2)}
{d.weeks[].days[worked>0].date:aggCount}
{d.weeks[].days[code='LATE'].date:aggCount}
{d.weeks[].days[code='PTO'].leave:aggSum:formatN(2)}
```

The total paid hours add the paid leave to the hours worked on each day before the sum: `{d.weeks[].days[].worked:add(.leave):aggSum:formatN(2)}`.

### 3\. Hide zeros and color the exceptions

An empty cell reads better than `0.00` for a day without overtime: `{d.weeks[i].days[i].overtime:formatN(2):ifEQ('0.00'):show('')}`. A weekend day without a schedule prints `Off` with `{d.weeks[i].days[i].schedIn:ifEM:show(Off)}`.

The code cell takes its color from a [switch case](/documentation/design/conditions/inline-conditions.md#switch-case) and the [:color](/documentation/design/advanced-features/colors.md) formatter: `{d.weeks[i].days[i].code:ifEQ(MISS):show(#B42318):ifEQ(LATE):show(#B45309):ifEQ(EARLY):show(#B45309):ifEQ(HOL):show(#667085):elseShow(#1E40AF):color(p)}`.

### 4\. Draw the month calendar

The calendar strip is a table with a [horizontal loop](/documentation/design/repetitions/with-arrays.md#horizontal-loops-repeat-columns): `{d.calendar[i].date:formatD(dd)}` and `{d.calendar[i].date:formatD(D)}` in one column, `{d.calendar[i+1]}` in the next. The day cell colors its background from the status with `:color(cell,background)`. Each generated column takes the width of the `[i]` column: size it for 28 to 31 days.

Save the DOCX template, connect it to your time and attendance data, and let Carbone generate one record per employee for each period.

## Related Examples

Check out these similar templates to learn more:

- [Weekly class timetable](/examples/timetable/index.md): XLSX template to XLSX.
- [Construction schedule report](/examples/planification-medium/index.md): DOCX template to PDF.
- [Project status report](/examples/mission-report/index.md): DOCX template to PDF.

## Related topics

- [Construction schedule report](/examples/planification-medium/index.md)
- [City walking tour itinerary](/examples/dynamic-pins-on-map/index.md)
- [Excel payroll register](/examples/payroll-register/index.md)
- [Product roadmap slide](/examples/s-product-roadmap/index.md)
- [Weekly class timetable](/examples/timetable/index.md)
