MySQL SECOND() Function with Example

MySQL SECOND() Function with Example

MySQL SECOND() function; In this tutorial, we would love to share with you how to use the MySQL second() function with the help of examples.

MySQL SECOND() Function

In MySQL, SECOND()  the function is used to return the second component from a time value.

Note: This function pass only one parameter and it will return value seconds of given time within the range 0 to 59.


The syntax of the second() of MySQL is below:


Here,time is the time value that you want to extract the seconds component from.


Let’s take a basic example of a second() function is below:

SELECT SECOND('10:35:29');


| SECOND('10:35:29') |
|                 29 |


Here’s, We take the second example using an abbreviated time value without colons.



| SECOND('1220') |
|             20 |


You can also use the EXTRACT () function to extract seconds (and other date / time parts) from the date / time value:



| EXTRACT(SECOND FROM '10:35:45') |
|                              45 |


We take a another example of second() function with NOW() function is below:

| SECOND(NOW())  |
|             10 |

Let’s look at some more MySQL SECOND() examples and explore how to use the SECOND() in MySQL. See the below more examples :

mysql> SELECT SECOND('2014-01-28 07:47:18.000004');
Result: 18

mysql> SELECT SECOND('2014-01-28 15:21:05');
Result: 5

mysql> SELECT SECOND('12:13:06');
Result: 6

mysql> SELECT SECOND('838:11:59');
Result: 59


Here, you have learned how to use MySQL SECOND() function with various examples.

Recommended MySQL Tutorials

If you have any questions or thoughts to share, use the comment form below to reach us.


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *