Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r0711

D toc

Excerpt

Formats a set of Unix timestamps according to a specified date formatting string.

Source values can be a reference to a column containing Unix timestamp values.

Info

NOTE: Date values must be converted to Unix timestamps before applying this function. Unix time measures the number of milliseconds that have elapsed since January 1, 1970 00:00:00 (UTC). See UNIXTIME Function.

Supported format strings for this function are the same as the supported format strings for the DATEFORMAT function. For more information on those string values, see Supported Data Types.

D s lang vs sql

D s
snippetBasic

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value: unixtimeformat(MyUnixDate, 'yyyy-MM-dd') as: 'unixDate'

unixtimeformat(MyUnixDate, 'yyyy-MM-dd')

Output: Returns the Unix timestamp values in the MyUnixDate column, converted to year-month-day format.

D s
snippetSyntax

D lang syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:unixtimeformat(unixtime_col, date_format_string)

unixtimeformat(unixtime_col, date_format_string)


ArgumentRequired?Data TypeDescription
unixtime_colYdatetimeName of column whose Unix timestamp values are to be formatted
date_format_stringYstringString literal identifying the date format to apply to the value

D s lang notes

unixtime_col

Name of the column whose Unix time data is to be formatted.

  • Missing values for this function in the source data result in missing values in the output.
  • Multiple columns and wildcards are not supported.

D s
snippetusage

 

Required?Data TypeExample Value
YesDatetime (formatted as Unix time integer values)myDate

date_format_string

String value indicating the date format to apply to the input values.

Info

NOTE: If the platform cannot recognize the date format string, the generated result is written as a string value.

For more information on the supported formatting strings, see below.

  • Missing values for this function in the source data result in missing values in the output.
  • Multiple columns and wildcards are not supported.

D s
snippetusage

Required?Data TypeExample Value
YesString'MM/dd/yyyy'

D s
snippetExamples

Example - Unix timestamp formatting variations

DescriptionunixTimestamp columnTransformnewUnixTimestamp column
Numeric date, year first

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'yyyy-MM-dd') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'yyyy-MM-dd')
p03NameNew column name
SearchTermNew formula

2016-02-08

2015-12-30

2015-04-26

Numeric date, American style

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'M/d/yy') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'M/d/yy')
p03NameNew column name
SearchTermNew formula

2/8/16

12/30/15

4/26/15

Full written date

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'MMMM dd, yyyy') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'MMMM dd, yyyy')
p03NameNew column name
SearchTermNew formula

February 08, 2016

December 30, 2015

April 26, 2015

Abbreviated date,
including abbreviated
day of week

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'EEE MMM dd, yyyy') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'EEE MMM dd, yyyy')
p03NameNew column name
SearchTermNew formula

Mon Feb 08, 2016

Wed Dec 30, 2015

Sun Apr 26, 2015

Full 24-hour time

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'HH:mm:ss.SSS') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'HH:mm:ss.SSS')
p03NameNew column name
SearchTermNew formula

15:42:00.000

00:00:00.000

07:07:00.00

Twelve-hour time with AM/PM indicator

1454946120000

1451433600000

1430032020000

D trans
RawWrangletrue
p03Value'newUnixTimestamp'
Typestep
WrangleTextderive type:single value:unixtimeformat(unixTimestamp,'h:mm:ss a') as:'newUnixTimestamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueunixtimeformat(unixTimestamp,'h:mm:ss a')
p03NameNew column name
SearchTermNew formula

Info

NOTE: For this function, use of the lower-case hour indicator (h or hh) requires the use of an AM/PM indicator (a).

3:42:00 PM

12:00:00 AM

7:07:00 AM

D s also
labeldate