Jump to content


Photo

Help in Date Query


  • Please log in to reply
3 replies to this topic

#1 elioncho

elioncho
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 07 October 2006 - 11:45 PM

Hi,

Suppose I have a table like this one

ID      DATE            NAME
1    2006-10-03    ELIAS
2    2006-10-04    ELIAS
3    2006-04-07    JOHN

I want the user to be able to do a search 'by month'  by selecting a month from a selection list. How can I compare the month the user chooses with the month in the DATE Format stored in the database? I there an esay way to compare the DATE format with a month?

Thanks,
ElĂ­as

#2 Firemankurt

Firemankurt
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts
  • LocationWashington State

Posted 09 October 2006 - 02:47 AM

SELECT *
FROM `table`
WHERE `DATE` LIKE '%-12-%'

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 09 October 2006 - 05:57 AM

SELECT *
FROM `table`
WHERE `DATE` LIKE '%-12-%'

Please don't -- use the MONTH() function that was designed for this purpose.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 elioncho

elioncho
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 09 October 2006 - 07:37 PM

thanks,

:P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users