
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to convert yyyymmdd in INT type to date?
For this, you can use the DATE() function. Let us first create a table −
mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.48 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(20190108); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(20161231); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(20170411); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------+ | Number | +----------+ | 20190108 | | 20161231 | | 20170411 | +----------+ 3 rows in set (0.00 sec)
Following is the query to convert yyyymmdd in int type to date −
mysql> select date(Number) from DemoTable;
This will produce the following output −
+--------------+ | date(Number) | +--------------+ | 2019-01-08 | | 2016-12-31 | | 2017-04-11 | +--------------+ 3 rows in set (0.00 sec)
- Related Articles
- How to Convert yyyymmdd to Normal Date Format in Excel?
- How to convert date YYYYMMDD to YY-MM-DD in MySQL query?
- How to convert date and time into int in Android sqlite?
- Convert masked array element to int Type in NumPy
- Golang Program to convert double type variables to int
- Golang Program to convert int type variables to String
- Swift Program to Convert Char type variables to Int
- Swift Program to convert int type variable to string
- Swift Program to convert int type variable to double
- Swift program to convert double type variables to int
- C++ Program to Convert long Type Variables to int
- C++ Program to Convert int Type Variables to long
- Golang Program to convert long type variables to int
- Golang Program to convert int type variables to long
- Haskell Program to convert int type variables to long

Advertisements