MINUTE(), MICROSECOND() and HOUR() functions in MySQL

1. MINUTE() :
The MySQL MINUTE() function is used for return the minute part of a datetime value. It can be between 0 to 59.When the datetime is passed in MINUTE() function then it will return the minute value .

Syntax –

MINUTE(datetime) 

Parameter –
It take parameter a dateline value.

Return –
It returns a minute numeric value between 0 to 59.

Example-1:



SELECT MINUTE ("2020-06-29 10:34:00"); 

Output –

34

Example-2:

SELECT MINUTE("4:10:17");

Output –

10



2. MICROSECOND() –
The Mysql function MICROSECOND() is used for return the microsecond part of datatime value .It can be between 0 to 999999.When the datetime is passed in MINUTE() function then it will return the microsecond value .

Syntax [-

MICROSECOND(datetime)

Parameter –
A datetime value.

Return –
Return an integer

Example-1:



SELECT MICROSECOND("2010-07-20 06:24:10.967423"); 

Output –

967423

Example-2:

SELECT MICROSECOND("2005-10-10 12:24:17.000007"); 

Output –

7

3. HOUR() :
The MySQL function HOUR() returns the hour part of a given datetime. It can be between 0 to 838.

Syntax –

HOUR(datetime) 

Parameter –
A datetime value.

Return –
It return an integer value.

Example-1:

SELECT HOUR("12:24:17.000007"); 

Output –

12

Example-2:

SELECT MICROSECOND(""838:59:59""); 

Output –

838

Supported Versions of MySQL :

  • MySQL 4.0
  • MySQL 4.1
  • MySQL 5.0
  • MySQL 5.1
  • MySQL 5.5
  • MySQL 5.6
  • MySQL 5.7

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.