Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql date select

Tags:

date

sql

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
like image 499
Julius Degutis Avatar asked Aug 03 '12 14:08

Julius Degutis


People also ask

How do I find the record for a specific date in SQL?

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.

What does date () do in SQL?

The date function DAY accepts a date, datetime, or valid date string and returns the Day part as an integer value.


1 Answers

select * from
yourtable where yourDateColumn < '2012-12-8' and yourDateColumn >= '2012-12-07'
like image 89
Gonzalo.- Avatar answered Oct 18 '22 20:10

Gonzalo.-