Welcome Guest, Not a member yet? Register   Sign In
mysql date filter
#1

[eluser]dbashyal[/eluser]
i have a date in the format of YYYY-MM-DD in the table and i want to select all rows that belongs to month = 01, is there any easy method to do this.

i have made a separate field for month and pulling data checking the month field, as the project was due soon.

But, I am wondering if i can do above query without creating separate field month coz sometime i may have to query for year or even day and then i have to store date in separate fields day, month and year.
#2

[eluser]Randy Casburn[/eluser]
Yes. You can use SELECT EXTRACT () to extract portions of a MySQL DATE type. It works like date_add() and date_sub().

Very Easy.

Hope this helps.

Randy
#3

[eluser]dbashyal[/eluser]
Code:
|----|------------|--------|
| id | date       | event  |
|----|------------|--------|
| 1  | 2008-12-01 | event1 |
| 2  | 2008-11-01 | event2 |
| 3  | 2008-10-01 | event3 |
|____|____________|________|

I have this table? how can i use that method to get all events that fall on the month of november.

thanks.
#4

[eluser]Randy Casburn[/eluser]
This is correct -- Wow did I read the question wrong! Thanks sock puppet.

@dbashyal -- please ignore my first post - I completely misunderstood your question.
#5

[eluser]dbashyal[/eluser]
Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB