# UNIXEPOCH

> UNIXEPOCH function in StackQL: convert a time value, with optional modifiers, to seconds since 1970-01-01 00:00:00 UTC.

Source: https://stackql.io/language-spec/functions/datetime/unixepoch

Returns a time value as the number of seconds since 1970-01-01 00:00:00 UTC (a Unix timestamp), after applying any modifiers.

See also:  
[[` SELECT `]](/language-spec/select) [[` DATETIME `]](/language-spec/functions/datetime/datetime-fn) [[` TIMEDIFF `]](/language-spec/functions/datetime/timediff)

* * * 

## Syntax

```sql
SELECT UNIXEPOCH(time_value [, modifier ...]) FROM <multipartIdentifier>;
```

## Arguments

__*time_value*__  
A time value in any format the date and time functions accept, such as `2024-01-01 00:00:00`, an ISO 8601 timestamp like `2024-01-01T00:00:00Z`, or `now`.

__*modifier*__  
Optional [date modifiers](/language-spec/functions/datetime/date_modifiers) such as `+1 day` or `-365 days`.  The `subsec` modifier keeps fractional seconds.

## Return Value(s)
Returns an integer, or a floating point number with `subsec`.  The result is `NULL` for an invalid time value.

* * *

## Examples

### Convert time values

The first two values are the same instant in two formats; the third adds a day:

```sql
SELECT UNIXEPOCH('2024-01-01 00:00:00') AS a,
UNIXEPOCH('2024-01-01T00:00:00Z') AS b,
UNIXEPOCH('2024-01-01', '+1 day') AS c;
```

```
|------------|------------|------------|
|     a      |     b      |     c      |
|------------|------------|------------|
| 1704067200 | 1704067200 | 1704153600 |
|------------|------------|------------|
```

### Filter rows by age

The following query returns the repositories in a GitHub organization that received a push in the last year:

```sql
SELECT name
FROM github.repos.repos
WHERE org = 'stackql-labs'
AND UNIXEPOCH(pushed_at) > UNIXEPOCH('now', '-365 days');
```

For more information, see [https://www.sqlite.org/lang_datefunc.html](https://www.sqlite.org/lang_datefunc.html)
