Jump to content

setting week start when grouping


joel24

Recommended Posts

Hi,

Has anyone else has stumbled across this problem? MySQL's <url=http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week]week[/url] function only allows for the week start to be Monday or Sunday.

 

How could I allow the user to set a week start day of any day and then group by the user specified week for reporting..?

Link to comment
https://forums.phpfreaks.com/topic/223111-setting-week-start-when-grouping/
Share on other sites

Maybe use php date() function to determine which day returns the weekday you want.  Then, you'll be able to increase the date by 7 days and use that day in your queries and count which week of the year it is.  I don't see a real need for anything like that except if you're doing workweeks.  In that case, you might building a full fledged application that needs to worry about DST, leap years and seconds, salary vs hourly, pay periods vs work weeks, etc.  Sorry, venting  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.