469,091 Members | 1,178 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,091 developers. It's quick & easy.

How to search by Year

how do i find a specific date? i typed this in and it didnt work

Expand|Select|Wrap|Line Numbers
  1. SELECT Category, ScreenSize, Title, Classification, MovieNo    
  2. from c_movie,c_cinema
  3. where category = 'Comedy' and ScreenSize = 's'
  4. where Year in '2009-%-%'
Apr 4 '10 #1
1 2791
chathura86
227 100+
i assume that you have a column named Year which has dates and
you want to select records for a specific year.

well mysql has a function year() which returns the year from a date

eg

SELECT YEAR('2010-03-31');
returns 2010,

so you can use that to filter from a year

Expand|Select|Wrap|Line Numbers
  1. SELECT Category, ScreenSize, Title, Classification, MovieNo
  2. from c_movie,c_cinema
  3. where category = 'Comedy' and ScreenSize = 's'
  4. and year(Year) in ('2009')
  5.  
Regards
Apr 4 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Twobridge | last post: by
4 posts views Thread by Sutharsan Nagasun | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.