> For the complete documentation index, see [llms.txt](https://docs.fieldmotion.com/fieldmotion-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fieldmotion.com/fieldmotion-api-docs/marketingexpenses/_getdt.md).

# \_getDT

Gathers data about Marketing Expenses and their linked Sources, filtered within a period of time:

* The ID of the Expense
* The ID of the Marketing Source linked to the retrieved Expense
* The cost of the Expense
* The date of the Expense

### Parameters

#### draw

A number which is echoed back to the caller. Useful for avoiding race conditions.

#### start

The number of entries skipped before the function starts retrieving Expenses.

#### length

The number of entries returned, if the "start" parameter is higher than 0, skipped entries are not included.

#### dateFrom

The earliest date where Marketing Expenses are valid to be retrieved\
(relates to the current date, e.g 2 days ago would be "-2")

#### dateTo

The latest date where Marketing Expenses are valid to be retrieved\
(relates to the current date, e.g an exact week later than today would be "7")

### Examples

For these examples: The function is called on 30th May, 2023.\
start = 0, length = 10, dateFrom = 10, dateTo = 31

```
FM_api(
    'MarketingExpenses_getDT',[
      'draw' => 1,
      'start' => 0,
      'length' => 10,
      'dateFrom' => 10,
      'dateTo' => 31
    ]
);
```

### Result:

```
{
    "data":[
        ["18","11",4,"19-06-2023",""]
    ],
"draw":1,"recordsTotal":"3","recordsFiltered":"1"
}
```

In this example: start = 0, length = 10, dateFrom = -2, dateTo = 14

```
FM_api(
    'MarketingExpenses_getDT',[
      'draw' => 2,
      'start' => 0,
      'length' => 10,
      'dateFrom' => -2,
      'dateTo' => 14
    ]
);
```

### Result:

```
{
    "data":[
        ["17","7",31,"31-05-2023",""],
        ["18","11",4,"19-06-2023",""]
    ],
    "draw":2,"recordsTotal":"3","recordsFiltered":"2"
}
```

#### On Failure

If the "draw" parameter is not set

```
{"error":"missing or invalid parameter: draw"}
```
