SECOND Function

Derives the seconds value from a Datetime value. Source value can be a a reference to a column containing Datetime values or a literal.
  • If the source Datetime value does not include a valid input for this function, a missing value is returned.
  • If the input values do not contain milliseconds, the generated output is expressed as integers from 0 to 59.
  • If the input values contain milliseconds, the generated output is a floating point value.

Basic Usage

derive type:single value:SECOND(MyDate)

Output: Generates a column of values that retrieve the two-digit hour values from the MyDate column.

Syntax

derive type:single value:SECOND(datetime_col)

ArgumentRequired?Data TypeDescription
datetime_colYdatetimeName of column whose second values are to be computed

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

datetime_col

Name of the column whose seconds 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.

Usage Notes:

Required?Data TypeExample Value
YesDatetimemyDate

Examples

Example - Date element functions

This example illustrates how a variety of date-related functions can be used to derive specific values out of a column of Datetime type.

  • YEAR - Returns the four-digit year value from a Datetime value. See YEAR Function.
  • MONTH - Returns the two-digit month value from a Datetime value. See MONTH Function.
  • MONTHNAME - Returns the full month name value from a Datetime value. See MONTHNAME Function.
  • DAY - Returns the day of the month as a numeric value from a Datetime value. See DAY Function.
  • HOUR - Returns the hour value on a 24-hour scale from a Datetime value. See HOUR Function.
  • MINUTE - Returns the minutes value from a Datetime value. See MINUTE Function.
  • SECOND - Returns the seconds value from a Datetime value. See SECOND Function.

Source:

date
2/8/16 15:41
12/30/15 0:00
4/26/15 7:07

Transform:

derive type:single value: YEAR (date)

derive type:single value: MONTH (date)

derive type:single value: MONTHNAME (date)

derive type:single value: DAY (date)

derive type:single value: HOUR (date)

derive type:single value: MINUTE (date)

derive type:single value: SECOND (date)

Results:

NOTE: If the source Datetime value does not contain a valid input for one of these functions, no value is returned. See the second_date column below.

dateyear_datemonth_datemonthname_dateday_datehour_dateminute_datesecond_date
2/8/16 15:4120162February81541
12/30/15 0:00201512December3000
4/26/15 7:0720154April2677

Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Dataprep Documentation
Need help? Visit our support page.