mysql - How to select the compute the range value of a given date? -


i have table below. want count , select values within month range.

table

here's query

  select count(*) c, monthname(file_date) mn   baguio_patrolcase   monthname(file_date) between 'january' , 'july'   group monthname(file_date)   order file_date 

my output

what want achive count , select values february june. how this?

when convert date month name, comparing strings. here 2 options want:

where month(file_date) between 2 , 6  file_date >= '2015-02-01' , file_date < '2015-07-01' 

the second better, because allows engine use index on file_date (if available).

also, between keeps end values (it inclusive). so, if want february through june, use months, rather 1 , 7.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -