TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL Temporal Data Types

Overview

In this tutorial, we will learn about MySQL Temporal Data Types. Temporal data types are data types that refer to date and time. MySQL provides data types for storing different kinds of temporal information.

Temporal data types

Temporal data types that are supported by MySQL are as follows:

  • TIME
  • DATE
  • DATETIME
  • TIMESTAMP
  • YEAR

TIME

The TIME data type can express the time of day or duration, and has a range of ‘-838:59:59’ to ‘838:59:59’. MySQL displays TIME values in ‘HH:MM:SS’ format, but TIME columns can be assigned using either strings or numbers.

DATE

The supported range is ‘100001-01’ to ‘9999-12-31’
MySQL retrieves DATE values in ‘YYYY-MM-DD’ format, but DATE columns can be assigned using either strings or numbers. For example, the date January 21,2001 would look like: ‘2001-01-21’

DATETIME

This data type allows date and time combinations. The supported range is ‘1000-01-01’ to ‘9999-12-31 23:59:59’.
MySQL, retrieves DATETIME values in ‘YYYY-MM-DD HH:MM:SS’ format.

TIMESTAMP

This data type can be used to express datetime values ranging from ‘1970-01-01 00:00:00’ to partway through the year 2037. The TIMESTAMP returns a string in the format ‘YYYY-MM-DD HH:MM:SS’ with a display width fixed at 19 characters. To obtain the values as a number, add +0 to the timestamp column. A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation.

YEAR

The YEAR data type is assigned using the syntax:

YEAR [(2|4)]

where the year can be in a two-digit o four-digit format.

The default is the four-digit format. In four-digit format, the allowable values are 70 to 69, representing years from 1970 to 2069. MySQL retrieves YEAR values in YYYY format.

The following terms stand for:

YYYY – year
MM – month
DD – day of the month
hh – hour
mm – minute
ss – second

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL Numeric Data types› MySQL PI() Function

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version