Skip to main content

UNIXTIME Function

Derives the Unixtime (or epoch time) value from a Datetime value. Source value can be a reference to a column containing Datetime values.

Unix time is a date-time format used to express the number of milliseconds that have elapsed since January 1, 1970 00:00:00 (UTC).

  • Unix time does not handle the extra seconds that occur on the extra day of leap years.

This function factors any timezone values in the inputs.

  • If you have a column with multiple time zones, you can convert the column to Unixtime so you can perform Date/Time operations with a standardized time zone.

  • If you want to work with local times, you can truncate the time zone or use other Date functions.

  • If the source Datetime value does not include a valid input for this function, a missing value is returned.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

Basic Usage

unixtime(MyDate)

Output: Returns the Unix time values from the MyDate column.

Syntax and Arguments

unixtime(datetime_col)

Argument

Required?

Data Type

Description

datetime_col

Y

datetime

Name of column whose Unix time values are to be computed

For more information on syntax standards, see Language Documentation Syntax Notes.

datetime_col

Name of the column whose Unix time value is to be computed.

  • Missing values for this function in the source data result in missing values in the output.

  • Invalid or out-of-range source values generate missing values in the output.

  • Multiple columns and wildcards are not supported.

  • Includes time zone offset when it converts Date/Time values to unixtime.

  • If the date value does not include a time zone, unixtime uses UTC (0:00).

Usage Notes:

Required?

Data Type

Example Value

Yes

Datetime

myDate

Examples

Tipp

For additional examples, see Common Tasks.

Example - Unix time generation and formatting

This example illustrates how you can use functions to manipulate Unix time values in a column of Datetime type.

Functions:

Item

Description

UNIXTIME Function

Derives the Unixtime (or epoch time) value from a Datetime value. Source value can be a reference to a column containing Datetime values.

Source:

date

2/8/16 15:41

12/30/15 0:00

4/26/15 7:07

Transformation:

Use the following transformation step to generate a column containing the above values as Unix timecode values:

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

UNIXTIME (date)

Parameter: New column name

'unixtime_date'

Results:

Anmerkung

If the source Datetime value does not contain a valid input for one of these functions, no value is returned.

date

unixtime_date

2/8/16 15:41

1454946120000

12/30/15 0:00

1451433600000

4/26/15 7:07

1430032020000