- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
STR_TO_DATE as column, but column not found?
You can use having clause. Let us first create a table −
mysql> create table DemoTable -> ( -> AdmissionDate varchar(100) -> ); Query OK, 0 rows affected (0.55 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('10/12/2017'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('01/11/2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('31/01/2019'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('09/06/2019'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('19/04/2019'); Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------+ | AdmissionDate | +---------------+ | 10/12/2017 | | 01/11/2018 | | 31/01/2019 | | 09/06/2019 | | 19/04/2019 | +---------------+ 5 rows in set (0.00 sec)
Following is the query to STR_TO_DATE as column −
mysql> select STR_TO_DATE(AdmissionDate, '%d/%m/%Y') as newDate from DemoTable -> having newDate >= '2019-01-01';
Output
+------------+ | newDate | +------------+ | 2019-01-31 | | 2019-06-09 | | 2019-04-19 | +------------+ 3 rows in set (0.00 sec)
- Related Articles
- How can we use MySQL function STR_TO_DATE(Column, ‘%input_format’)?
- MySQL Order By date column and integer column, but specify ordering rules of integer column? Is it possible?
- Exclude rows based on column value when another duplicate column value is found in MySQL?
- Update one column data to another column in MySQL if the second column is NOT NULL?
- Setting column values as column names in the MySQL query result?
- Does using SERIAL as column name already includes 'NOT NULL' in MySQL?
- Create a column on my table that allows null but is set by default to empty (not null)?
- What MySQL returns if specified format string is not as per accordance with the date string passed as arguments to STR_TO_DATE() function?
- Empty string in not-null column in MySQL?
- Removing NOT NULL restriction from column in MySQL?
- Set existing column as Primary Key in MySQL?
- Return a masked array containing the same data but with a new shape viewed as column-major order in Numpy
- SELECT not null column from two columns in MySQL?
- How to add a NOT NULL column in MySQL?
- Change a MySQL column to have NOT NULL constraint

Advertisements