sql - MySQL function to get list of Mondays -


What is the most effective way to get a list of all specific Mondays from the date fields?

When I'm not concerned about efficiency, I have done something like this:

DATE-weekday (DATE) + 1 . But now I need to calculate this on a large dataset and I do not want my user being interested in Rubik's cube as it is taking too long

edit:
What I need is a list of all weeks in which records are. I am preparing a payroll report where the user will select a week to filter the report.

Here is the one who came with me:

  SELECT DISTINCT ((DATE (`Timestart`) - Dophokie (` TimeStart`)) + 2) 1 by DESC By time` command  

Is there any improvement to suggest anyone?

"Date Field to Unique Monday":

 From the `table` to SELECT DISTINCT (` date`), where WEEKDAY (`date`) = 0  

" The week in which we have date values ​​should be as simple as:

  SELECT DISTINCT (WEEK (`date`)) WHERE year (` date`) from `table` = 2010; SELECT WEEK (now ()), YEAR (now ()); + ------------- + ------------- + | WEEK (now ()) | Year (now ()). + ------------- + ------------- + | 31 | 2010 | + ------------- + ------------- +  

Who will also benefit you in your other payroll? By using things using PF

  WHERE WEEK (`dated`) = 31  

, trust mysql to handle things from there.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -