I want to write a select statement to find a date from my database.
In the database I have a field action_date
as a date type with dates like this: 7/12/2012 17:21:33
.
How do I get all data from after the specified date?
So if I have db like this:
7/12/2012 17:21:33
7/12/2012 15:21:35
8/12/2012 8:25:35
9/12/2014 8:25:35
I want get only these rows:
7/12/2012 17:21:33
7/12/2012 15:21:35
You can use DATE() from MySQL to select records with a particular date. The syntax is as follows. SELECT *from yourTableName WHERE DATE(yourDateColumnName)='anyDate'; To understand the above syntax, let us first create a table.
The date function DAY accepts a date, datetime, or valid date string and returns the Day part as an integer value.
select * from
yourtable where yourDateColumn < '2012-12-8' and yourDateColumn >= '2012-12-07'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With