search
Search
Publish
menu
menu search toc more_vert
Robocat
Guest 0reps
Thanks for the thanks!
close
chevron_left Date and Time
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
help Ask a question
Share on Twitter
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
A
A
share
thumb_up_alt
bookmark
arrow_backShare
Twitter
Facebook
chevron_left Date and Time
thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings

MySQL | TIME

Database
chevron_right
MySQL
chevron_right
Documentation
chevron_right
Data types
chevron_right
Date and Time
schedule Mar 9, 2022
Last updated
local_offer MySQL
Tags
tocTable of Contents
expand_more

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
Ask a question or leave a feedback...