D
D
Dmitry Gavrilenko2016-02-04 10:04:11
SQL Server
Dmitry Gavrilenko, 2016-02-04 10:04:11

How to take into account the number of weeks in a SQL query?

There is a task. In SQL query, 2 dates "from" and "to" can be substituted.
You need to take "from", round up to the 1st of the month. From "to" is the same only until the last day of the month.
It is necessary to calculate how many calendar weeks are affected during this period and in the future to use these time periods as selection conditions from another table. How to implement it?
Week count example:
******1
2*****8
9*****15
16*****22 23 *****
28
29.30

  1. eleven
  2. 2 - 8
  3. 9 - 15
  4. 16 - 22
  5. 23 - 28
  6. 29 - 30

Such here dynamic, depending on a month, the answer should come. I'm not sure that this can be done purely in SQL, but I still decided to ask you for confirmation.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question