Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

MySQL Second Function

by suresh

MySQL Second function is one of the Date Function, which is used to return the Seconds value from a given time. This function returns integer value range from 0 to 59.

In this article, we will show you, How to use this MySQL Second function to get the seconds value from the given time expression with an example.

MySQL Second Syntax

The basic syntax of the Second() Function in MySQL is as shown below:

SECOND(Time or expression);

MySQL Second function Example

The below shown queries helps you understand the use of this Second function. Here, we are returning the Second value from the different time expression, and the Datetime expression.

SELECT SECOND('10:22:45');

SELECT SECOND('2019-02-05 10:20:12');

SELECT SECOND('2019-02-05 10:20:59.112352');

OUTPUT

MySQL Second Function 1

MySQL Second Function Example 2

In this example, we are returning Seconds value from the current date and time returned by the Now() function, UTC_TIME function, and UTC_TIMESTAMP function.

SELECT NOW(), SECOND(NOW());

SELECT UTC_TIME(), SECOND(UTC_TIME());

SELECT UTC_TIMESTAMP(), SECOND(UTC_TIMESTAMP());

OUTPUT

MySQL Second Function 2

Here, we are trying to return the seconds value from String dateTime format, HHMMSS formats. Within the last statement, we used the zero hour part.

SELECT NOW(), SECOND(NOW() + 10);  

SELECT SECOND(101235);

SELECT SECOND('00:12:22');

OUTPUT

MySQL Second Function 3

MySQL Second Example 3

In this example, we will show you, how to use this Second function on a table data. Here, we are returning the seconds value from the Hire Date column.

SELECT EmpID,
FirstName,
LastName,
Occupation,
YearlyIncome,
Sales,
HireDate,
SECOND(HireDate)
FROM `MySQL Tutorial`.customer;

OUTPUT

MySQL Second Function 4

Thank You for Visiting Our Blog

Placed Under: MySQL

Trending Posts

JavaScript Round

Java Break Statement

JavaScript SubString

Power BI Page Level Filters

SQL @@SPID

MySQL ASIN Function

Comparison Operators in R

SQL PIVOT

C Program to Reverse Order of Words in a String

Java Leap Year Program

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy