hi friends,
i want search by month and year. how can i give, i am facing problem with this. please give some idea.
in database table, date foramte is like this 2007-12-06. i want search with 12-2007. i want display the records under each month. please help to me.
thanks,
qumar.
search by month and year
Moderator: General Moderators
Choose the Right Board
I would advise you to alter your database table, adding fields month, day, and year. This way you can search for what you want with a simple select query.
The way it is now, you'd have to select all dates, loop through the result set, explode() on the '-' character, and then look for the month you want.
Moved to databases:
The way it is now, you'd have to select all dates, loop through the result set, explode() on the '-' character, and then look for the month you want.
Moved to databases:
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Choose the Right Board
Not Necessary. Why not Just..scottayy wrote:I would advise you to alter your database table, adding fields month, day, and year. This way you can search for what you want with a simple select query.
The way it is now, you'd have to select all dates, loop through the result set, explode() on the '-' character, and then look for the month you want.
Code: Select all
Select * from `dates` where `date` >= '2007-12-01' AND `date` <= '2007-12-31'
Code: Select all
Select * from `dates` where MONTH(date) = 12 AND YEAR(date) = 2007
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I was thinking along those lines.. almost posted something about doing date conversion/comparing in the query, but I couldn't say it with enough confidence.. so I didn't say it. 
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA