0

How to select database rows by days ,month,years

I have table like this

id count generatedAt 1 130 2013-01-13 02:21:02 2 120 2013-01-08 04:15:06 3 89 2013-01-08 01:42:57 4 24 2012-11-25 05:31:43 5 3 2012-02-31 09:25:24 

I would like to select the rows by day or month or year.

For example by day.

2-3 is same day so I need only 1,2,4,5

for example by month,1,2,3 is same month so I need only 1,4,5

for year I need only 1,4

How can I make it?

I am using doctorine2

1 Answer 1

2

You can do something like this . .
you can choose a date , month or specific year to select rows.

select * from TabeName //for days where DAY(myDate) = 20 //for month MONTH(myDate) = 12 // for year YEAR(myDate) = 2008 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks,I understand but I need to use this in doctorine2 so I will check these articles as well.stackoverflow.com/questions/18826836/… Thanks to you I can step forward!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.