---
title: "Example 6 - Adding/Editing Timesheet Line Item - Start time should be before end time"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5986353153/Example+6+-+Adding%2FEditing+Timesheet+Line+Item+-+Start+time+should+be+before+end+time"
format: markdown
---
For Details check: [https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5381455880](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5381455880) 

This example might not have an immediate practical use, but it can serve as a starting point for creating one.

It shows how to prevent adding or updating a timesheet line item if the start date and time are later than the end date and time.

```
{
    "Id": "EXAMPLE-6",
    "Name": "TSLI start-end date",
    "Code__c": null,
    "Error_Message__c": "End time must be later than start",
    "Formula__c": "",
    "SwiftFormula": {
        "params": [
            {
                "var": "${START}",
                "table": "FIELDBUDDY__Timesheet_Lineitem__c",
                "field": "FIELDBUDDY__Start_Time__c"
            },
            {
                "var": "${END}",
                "table": "FIELDBUDDY__Timesheet_Lineitem__c",
                "field": "FIELDBUDDY__End_Time__c"
            }
        ],
        "formula": "f=()=>{return (new Date('${START}').valueOf()) >= (new Date('${END}').valueOf()); };Boolean(f());"
    },
    "Mobile_Page__r": "Timesheet Lineitem"
}
```


![image](media://13ee451e-22e2-489a-80ec-f585c561ad26)


```
EXAMPLE-6 TSLI start-end date at Timesheet Lineitem
f=()=>{return (new Date('2025-01-08 15:16').valueOf()) >= (new Date('2025-01-08 13:17').valueOf()); };Boolean(f());
Pass: false
ErrorMessage: End time must be later than start
```