---
title: Examples
url: https://www.tines.com/docs/formulas/examples/
updated: 2022-11-10T20:12:35+00:00
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md)*

# Examples

*[View on tines.com](https://www.tines.com/docs/formulas/examples/)*

### Access data from an upstream action’s event

```
upstream_action.path.to.value
```

See more information on referencing data.

### Count the number of items in an array

```python
SIZE(my_array)
```

See the full list of [functions](https://www.tines.com/docs/functions/).

### Multiply two numbers

```python
my_number * 10
```

See the full list of [operators](https://www.tines.com/docs/operators/).

### Generate a random number between 1 and 10

```python
RANDOM(1, 10)
```

### Get the current date and time in yyyymmdd Format

```python
DATE("now", "%Y%m%d")
```

### Get the time 24 hours ago

```python
DATE(DATE("now", "%s") - 24 * 60 * 60, "%Y-%m-%dT%l:%M:%S%z")
```

### Select all the elements in an array where the key has the given value

Input:

```python
[
  {
    "color": "red",
    "index": "1"
  },
  {
    "color": "blue",
    "index": "2"
  },
  {
    "color": "green",
    "index": "3"
  }
]
```

```python
WHERE(my_array, "index", "1")
```

Output:

```python
[{"color":"red","index":"1"}]
```

### Select all the elements in an array that regex match the string "r"

Input:

```python
[
  "red",
  "blue",
  "green"
]
```

```python

FILTER(my_array, LAMBDA(element, MATCH(element, "r")))
```

Output:

```python
["red","green"]
```

### Get the difference between two arrays (i.e. get elements from one that are not present in the other)

Input:

```python
array_one = [
  "dog",
  "cat",
  "turtle",
  "dinosaur",
  "lizard",
  "chicken",
  "koala"
]
array_two = [
  "cat",
  "elephant",
  "giraffe",
  "penguin",
  "tiger",
  "koala"
]
```

```python
FILTER(array_two, LAMBDA(arr_two_elem, NOT(INCLUDES(array_one, arr_two_elem))))
```

Output:

```python
[
  "elephant",
  "giraffe",
  "penguin",
  "tiger"
]
```

### Construct an array of objects from an input array

Input:

```python
[
  "foo@tines.com", 
  "bar@tines.com"
]
```

```python
MAP_LAMBDA(email_array, LAMBDA(elem, OBJECT(\"email_address\", OBJECT(\"address\", elem))))
```

Output:

```python
[
  {
    "email_address": {
      "address": "foo@tines.io"
    }
  },
  {
    "email_address": {
      "address": "bar@tines.io"
    }
  }
]
```
