

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How to convert date YYYYMMDD to YY-MM-DD in MySQL query?
- Convert masked array element to int Type in NumPy
- How to convert date and time into int in Android sqlite?
- How to convert from string to date data type in MongoDB?
- How to convert int to String in java?
- How to convert bool to int in MySQL?
- How to convert int to string in Python?
- MongoDB – Fix “Failed to convert from type String to type Date”?
- Convert String to Java int
- How to convert an int to string in C++?
- How to convert Int to Hex String in Kotlin?
- Convert int to String in Java
- Convert INT to DATETIME in MySQL?
- How to convert a Java String to an Int?
- How to convert epoch Date to meaningful JavaScript date?
Advertisements