php - Logical Query to calculate weeks -


i ask user enter start , end date in application. calculate no. of weeks in between these 2 dates.

i want fetch documents created per week in given period of time. unable implement logic me fetch first week, second week, third week, , on.

i use input database , create graph. using php server side language. suggest me algorithm.

ex:

start date: 20/07/2012  end date: 19/02/2013.  total no. of days: 214.  total no. of weeks: 30 (30 weeks , 4 days) 

i want fetch period of 20/07/2012 27/07/2012 , no. of docs during period. till 15/02/2013.

without seeing database structure here sample of require

select year(doc_created) report_year, weekofyear(doc_created) report_week, count(*) doc_count documents doc_created between '2012-07-20' , '2013-07-19' group year(doc_created), weekofyear(doc_created) 

grouping weekofyear not enough, period may overlap next year, should include year.

possible results:   year  week  docs   2012  1     4   2012  3     1   2013  1     65   2013  2     4   

as can see 2012 week 1 overlap 2013 week 1, if used week number.

for grid/graph use reference (year wk) , amount (docs)
e.g. 2012wk1 4, 2012wk3 1


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -