![]() |
mySQL query for every 4 week block in a calendar week?
I have a table with about 5 years of dates (2011 - 2016).
Each date is stored in a column called "dt" as YYY-MM-DD (ie. 2012-01-04) and "y" as year (2012, 2013). I also have a column called "w" which is the week number for each week in the calendar year which helps. It resets to 0 for the first week of each year and then increments to 52 to the last week. I am trying to find the correct MYSQL SELECT query to extract 4 week blocks (pay periods) from each calendar year. So for 2014, one would expect 13 pay blocks.. I want to return the results as follows: Period 1 Week 1 (2012-12-31 to 2012-01-05) Week 2 (2012-01-06 to 2012-01-12) Week 3 (2012-01... Week 4 (2012.. Period 2 Week 5 (2012.. Week 6 (2012.. Week 7 (2012.. ... Period 3 .. .. Period 13 .. Code:
$currentYear="2014" |
You know, there really was no reason to have the Y and W columns in that table.
MySQL could easily derive both of those from the DT field. But oh well, since you have them, let's use them. Anyway, the point you are completely missing is *WHAT* you want to show for each week. That is, do you want to show the detailed payroll (every paycheck for every person) for each week? Or so you want to show the total payroll for the week? Or what? No, you CERTAINLY should *NOT* do a FOR loop getting one week at a time. Yuck. But you need to tell us what data you want to display for each week. |
| All times are GMT +1. The time now is 09:04 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.