472,145 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 2856
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
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.