filter middle field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alhie
Forum Newbie
Posts: 1
Joined: Wed Feb 10, 2010 10:07 pm

filter middle field

Post by alhie »

I have a problem... i want to filter my table on date field for month... n my code like this :

"SELECT * FROM table WHERE substr(datefield,5,2)='02' ";

correct please ... :mrgreen:
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: filter middle field

Post by pbs »

What is data type of your date field
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: filter middle field

Post by John Cartwright »

Assuming your using the mysql DATE columns.. you could do

Code: Select all

"SELECT * FROM table WHERE MONTH(datefield) = 2";
Post Reply