I have a table in the MySQL database that is set up with DATETIME
. I need to SELECT
in this table only by DATE and excluding the time.
How d
SELECT DATE(ColumnName) FROM tablename;
More on MySQL DATE() function.
Please try this answer.
SELECT * FROM `Yourtable` WHERE date(`dateField`) = '2018-09-25'
In MYSQL we have function called DATE_FORMAT(date,format). In your case your select statement will become like this:-
SELECT DATE_FORMAT(dateTimeFieldName,"%a%m%Y") as dateFieldName FROM table_name
For more information about Mysql DATE and TIME functions click here.
Try
SELECT * FROM Profiles WHERE date(DateReg)=$date
where $date is in yyyy-mm-dd
Alternatively
SELECT * FROM Profiles WHERE left(DateReg,10)=$date
Cheers
Use DATE_FORMAT
select DATE_FORMAT(date,'%d') from tablename =>Date only
example:
select DATE_FORMAT(`date_column`,'%d') from `database_name`.`table_name`;
In the interest of actually putting a working solution to this question:
SELECT ... WHERE `myDateColumn` >= DATE(DATE_FORMAT(NOW(),'%Y-%m-%d'));
Obviously, you could change the NOW() function to any date or variable you want.