search
Search
Login
Unlock 100+ guides
menu
menu
web
search toc
close
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to

MySQL | TIME

schedule Aug 11, 2023
Last updated
local_offer
MySQL
Tags
tocTable of Contents
expand_more
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

MySQL's TIME type is used when we do not need information about the date. It has the following syntax:

'hh:mm:ss' ('hhh:mm:ss' --format for large hours values)

A few useful points to note:

  • The supported range is '-838:59:59' to '838:59:59'.

  • The possible hour value is greater than 24 as time values can also be used to represent time intervals.

  • Values that are outside the valid TIME range but are otherwise valid are converted to the closer of the upper or lower TIME range limit.

  • Invalid TIME values are converted to '00:00:00'

Assumption of abbreviated values

If you do not provide the TIME value in full, the following assumptions are made when converting:

Colon

Example value

Assumption

Converted value

YES

'11:12'

Colons are taken to represent time of day

'11:12:00'

NO

'1112'

Represent time interval. Two rightmost digits represent seconds.

'00:11:12'

Fractional Seconds

A TIME value can store a fractional seconds portion for microseconds (up to 6 digits precision).

'hh:mm:ss.ffffff'
NOTE

The delimiter between seconds and microseconds must be a dot (.)

For the fractional seconds to be stored, the column must be defined to accept fractional seconds up to specific precision. The general syntax is as follows:

column_name type_name(fsp);

TIME, DATETIME, TIMESTAMP data types can hold fractional second information:

CREATE TABLE sample_table (column1 TIME(3), column2 DATETIME(6), column3 TIMESTAMP(1));
robocat
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
1
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!