Mastering the SECOND Function in Looker Studio: Extraction, Usage, Examples, and Limitations

 Mastering the SECOND Function in Looker Studio: Extraction, Usage, Examples, and Limitations

Discover the power that hides within the

SECOND
function in Google Data Studio. Used to extract the seconds component from a given date, the
SECOND
function simplifies the time analysis process by allowing you to isolate and observe the seconds part of your data. This function is especially handy when you're dealing with precise time-based metrics or when you need granular-level details.

Syntax

The

SECOND
function carries two types of syntax:

  1. This syntax is utilized when we want to extract the seconds component from a Date & Time value:

    SECOND(datetime_expression)
    The
    datetime_expression
    can be either a Date & Time field or expression.

  2. This syntax is used for compatibility mode Date value extraction. In addition,

    Input Format
    is optionally provided in case X isn't appropriately configured as a semantic date field:
    SECOND(X [,Input Format])
    Here,
    X
    can be a field or expression resulting in Text, Number, or compatibility mode Date. The
    Input Format
    is used to properly interpret the compatibility mode dates.

The

SECOND
function supports various input formats for compatibility mode dates, ranging from 'BASIC', 'DEFAULT_DASH', 'DEFAULT_SLASH', to specific formats like 'RFC_1123', 'RFC_3339', and 'DECIMAL_DATE'. For Numeric fields or expressions, it accepts 'SECONDS', 'MILLIS', 'MICROS', 'NANOS', and 'JULIAN_DATE'.

Usage

Although the Google Data Studio

SECOND
function seems simple, it's a powerful tool to use when dealing with precise time data. To use the function, simply place your Date & Time field or expression within the parentheses (), or for compatibility mode dates, provide your field/expression and optionally, the Input Format.

Examples

Say, you run an online store and want to analyze the precise time when a purchase was made. You have the transaction timestamp which you want to break down.

  1. To get the seconds part from a date-time expression that is timestamp of the transaction:

SECOND(Transaction_timestamp)

  1. Suppose the timestamp is in text format like "2022/01/01-14:20:45". To get the seconds:

SECOND("2022/01/01-14:20:45", 'BASIC')

  1. When the timestamp is stored as milliseconds since the Epoch:
    SECOND(Transaction_timestamp_millis, 'MILLIS')

Remember, the function will return a result between 0-59 which represents the seconds component of the date.

Function Limitations

Keep in mind that the

SECOND
function is designed to only retrieve the 'seconds' portion of a dateime. It won't return minutes, hours, or any other components. Also, it works with both compatibility mode dates and upgraded Date and Date & Time data types.

Helpful Tips

Some tips to keep in mind:

  • Make sure to match the correct input format with the data type of your source field or expression.
  • Deployment of the
    SECOND
    function can be especially beneficial when coupled with other time-based functions for comprehensive time-series analysis.
  • Use
    SECOND
    function in calculated fields to create new metrics at granular level.

Remember, every second counts, and so does the

SECOND
function in Google Data Studio! Compute wisely!

More function to use with Looker Studio

DATETIME_DIFF
:
Understanding and Leveraging the DATETIME_DIFF Function in Looker Studio for Efficient Data Analysis and Visualization
NULLIF
:
Understanding and Utilizing the NULLIF Function in Looker Studio for Comprehensive Data Analysis
DATETIME
:
How to use the DATETIME function
STDDEV
:
Understanding the Power of the STDDEV Function in Looker Studio for Improved Data Analysis and Strategic Decision Making
CASE WHEN
:
Data Transformation with CASE WHEN in Looker Studio

Become a Looker Studio expert
for free

Learn all the secrets of data analysis and create beautiful and effective dashboards thanks to our 30-second video courses! Join Catchr's community on YouTube.

Get more video lessons

All your data on Looker Studio

Build Looker Studio dashboard easily with your marketing data from all platforms and track your essential KPIs! No-code integration.

Start free trial now!
Looker studio

Optimize your data analysis

Get free Looker Studio dashboard template among a large collection of +50 stunning template! Elevate your data visualization.

Get free templates!