> On May 4, 2019, at 21:24, Thomas Kurz <sqlite.2...@t-net.ruhr> wrote:
> 
>> What about just sticking with the ISO week definition?
>> 
>> https://en.wikipedia.org/wiki/ISO_week_date
> 
> From the document you cited:
> 
> "The ISO standard does not define any association of weeks to months."

True enough, even though one could convert a 'week of year' into a 'week of 
month':

with
DayRange( day, until )
as
(
  select '2019-01-01' as day,
         '2019-12-31' as until

  union all
  select  date( DayRange.day, '+1 day' ) as day,
          DayRange.until
  from    DayRange

  where   date( DayRange.day, '+1 day' ) <= DayRange.until
),
DateRange
as
(
  select  day,
          cast( strftime( '%Y', day ) as number ) as year,
          cast( strftime( '%m', day ) as number ) as month,
          cast( strftime( '%W', day ) as number ) as week -- where is '%V' when 
one needs it :P
  from    DayRange
)
select  DateRange.*,
        dense_rank() over( partition by year, month order by week ) as 
week_of_month
from    DateRange;


2019-01-01|2019|1|0|1
2019-01-02|2019|1|0|1
2019-01-03|2019|1|0|1
2019-01-04|2019|1|0|1
2019-01-05|2019|1|0|1
2019-01-06|2019|1|0|1
2019-01-07|2019|1|1|2
2019-01-08|2019|1|1|2
2019-01-09|2019|1|1|2
2019-01-10|2019|1|1|2
2019-01-11|2019|1|1|2
2019-01-12|2019|1|1|2
2019-01-13|2019|1|1|2
2019-01-14|2019|1|2|3
2019-01-15|2019|1|2|3
2019-01-16|2019|1|2|3
2019-01-17|2019|1|2|3
2019-01-18|2019|1|2|3
2019-01-19|2019|1|2|3
2019-01-20|2019|1|2|3
2019-01-21|2019|1|3|4
2019-01-22|2019|1|3|4
2019-01-23|2019|1|3|4
2019-01-24|2019|1|3|4
2019-01-25|2019|1|3|4
2019-01-26|2019|1|3|4
2019-01-27|2019|1|3|4
2019-01-28|2019|1|4|5
2019-01-29|2019|1|4|5
2019-01-30|2019|1|4|5
2019-01-31|2019|1|4|5
2019-02-01|2019|2|4|1
2019-02-02|2019|2|4|1
2019-02-03|2019|2|4|1
2019-02-04|2019|2|5|2
2019-02-05|2019|2|5|2
2019-02-06|2019|2|5|2
2019-02-07|2019|2|5|2
2019-02-08|2019|2|5|2
2019-02-09|2019|2|5|2
2019-02-10|2019|2|5|2
2019-02-11|2019|2|6|3
2019-02-12|2019|2|6|3
2019-02-13|2019|2|6|3
2019-02-14|2019|2|6|3
2019-02-15|2019|2|6|3
2019-02-16|2019|2|6|3
2019-02-17|2019|2|6|3
2019-02-18|2019|2|7|4
2019-02-19|2019|2|7|4
2019-02-20|2019|2|7|4
2019-02-21|2019|2|7|4
2019-02-22|2019|2|7|4
2019-02-23|2019|2|7|4
2019-02-24|2019|2|7|4
2019-02-25|2019|2|8|5
2019-02-26|2019|2|8|5
2019-02-27|2019|2|8|5
2019-02-28|2019|2|8|5
2019-03-01|2019|3|8|1
2019-03-02|2019|3|8|1
2019-03-03|2019|3|8|1
2019-03-04|2019|3|9|2
2019-03-05|2019|3|9|2
2019-03-06|2019|3|9|2
2019-03-07|2019|3|9|2
2019-03-08|2019|3|9|2
2019-03-09|2019|3|9|2
2019-03-10|2019|3|9|2
2019-03-11|2019|3|10|3
2019-03-12|2019|3|10|3
2019-03-13|2019|3|10|3
2019-03-14|2019|3|10|3
2019-03-15|2019|3|10|3
2019-03-16|2019|3|10|3
2019-03-17|2019|3|10|3
2019-03-18|2019|3|11|4
2019-03-19|2019|3|11|4
2019-03-20|2019|3|11|4
2019-03-21|2019|3|11|4
2019-03-22|2019|3|11|4
2019-03-23|2019|3|11|4
2019-03-24|2019|3|11|4
2019-03-25|2019|3|12|5
2019-03-26|2019|3|12|5
2019-03-27|2019|3|12|5
2019-03-28|2019|3|12|5
2019-03-29|2019|3|12|5
2019-03-30|2019|3|12|5
2019-03-31|2019|3|12|5
2019-04-01|2019|4|13|1
2019-04-02|2019|4|13|1
2019-04-03|2019|4|13|1
2019-04-04|2019|4|13|1
2019-04-05|2019|4|13|1
2019-04-06|2019|4|13|1
2019-04-07|2019|4|13|1
2019-04-08|2019|4|14|2
2019-04-09|2019|4|14|2
2019-04-10|2019|4|14|2
2019-04-11|2019|4|14|2
2019-04-12|2019|4|14|2
2019-04-13|2019|4|14|2
2019-04-14|2019|4|14|2
2019-04-15|2019|4|15|3
2019-04-16|2019|4|15|3
2019-04-17|2019|4|15|3
2019-04-18|2019|4|15|3
2019-04-19|2019|4|15|3
2019-04-20|2019|4|15|3
2019-04-21|2019|4|15|3
2019-04-22|2019|4|16|4
2019-04-23|2019|4|16|4
2019-04-24|2019|4|16|4
2019-04-25|2019|4|16|4
2019-04-26|2019|4|16|4
2019-04-27|2019|4|16|4
2019-04-28|2019|4|16|4
2019-04-29|2019|4|17|5
2019-04-30|2019|4|17|5
2019-05-01|2019|5|17|1
2019-05-02|2019|5|17|1
2019-05-03|2019|5|17|1
2019-05-04|2019|5|17|1
2019-05-05|2019|5|17|1
2019-05-06|2019|5|18|2
2019-05-07|2019|5|18|2
2019-05-08|2019|5|18|2
2019-05-09|2019|5|18|2
2019-05-10|2019|5|18|2
2019-05-11|2019|5|18|2
2019-05-12|2019|5|18|2
2019-05-13|2019|5|19|3
2019-05-14|2019|5|19|3
2019-05-15|2019|5|19|3
2019-05-16|2019|5|19|3
2019-05-17|2019|5|19|3
2019-05-18|2019|5|19|3
2019-05-19|2019|5|19|3
2019-05-20|2019|5|20|4
2019-05-21|2019|5|20|4
2019-05-22|2019|5|20|4
2019-05-23|2019|5|20|4
2019-05-24|2019|5|20|4
2019-05-25|2019|5|20|4
2019-05-26|2019|5|20|4
2019-05-27|2019|5|21|5
2019-05-28|2019|5|21|5
2019-05-29|2019|5|21|5
2019-05-30|2019|5|21|5
2019-05-31|2019|5|21|5
2019-06-01|2019|6|21|1
2019-06-02|2019|6|21|1
2019-06-03|2019|6|22|2
2019-06-04|2019|6|22|2
2019-06-05|2019|6|22|2
2019-06-06|2019|6|22|2
2019-06-07|2019|6|22|2
2019-06-08|2019|6|22|2
2019-06-09|2019|6|22|2
2019-06-10|2019|6|23|3
2019-06-11|2019|6|23|3
2019-06-12|2019|6|23|3
2019-06-13|2019|6|23|3
2019-06-14|2019|6|23|3
2019-06-15|2019|6|23|3
2019-06-16|2019|6|23|3
2019-06-17|2019|6|24|4
2019-06-18|2019|6|24|4
2019-06-19|2019|6|24|4
2019-06-20|2019|6|24|4
2019-06-21|2019|6|24|4
2019-06-22|2019|6|24|4
2019-06-23|2019|6|24|4
2019-06-24|2019|6|25|5
2019-06-25|2019|6|25|5
2019-06-26|2019|6|25|5
2019-06-27|2019|6|25|5
2019-06-28|2019|6|25|5
2019-06-29|2019|6|25|5
2019-06-30|2019|6|25|5
2019-07-01|2019|7|26|1
2019-07-02|2019|7|26|1
2019-07-03|2019|7|26|1
2019-07-04|2019|7|26|1
2019-07-05|2019|7|26|1
2019-07-06|2019|7|26|1
2019-07-07|2019|7|26|1
2019-07-08|2019|7|27|2
2019-07-09|2019|7|27|2
2019-07-10|2019|7|27|2
2019-07-11|2019|7|27|2
2019-07-12|2019|7|27|2
2019-07-13|2019|7|27|2
2019-07-14|2019|7|27|2
2019-07-15|2019|7|28|3
2019-07-16|2019|7|28|3
2019-07-17|2019|7|28|3
2019-07-18|2019|7|28|3
2019-07-19|2019|7|28|3
2019-07-20|2019|7|28|3
2019-07-21|2019|7|28|3
2019-07-22|2019|7|29|4
2019-07-23|2019|7|29|4
2019-07-24|2019|7|29|4
2019-07-25|2019|7|29|4
2019-07-26|2019|7|29|4
2019-07-27|2019|7|29|4
2019-07-28|2019|7|29|4
2019-07-29|2019|7|30|5
2019-07-30|2019|7|30|5
2019-07-31|2019|7|30|5
2019-08-01|2019|8|30|1
2019-08-02|2019|8|30|1
2019-08-03|2019|8|30|1
2019-08-04|2019|8|30|1
2019-08-05|2019|8|31|2
2019-08-06|2019|8|31|2
2019-08-07|2019|8|31|2
2019-08-08|2019|8|31|2
2019-08-09|2019|8|31|2
2019-08-10|2019|8|31|2
2019-08-11|2019|8|31|2
2019-08-12|2019|8|32|3
2019-08-13|2019|8|32|3
2019-08-14|2019|8|32|3
2019-08-15|2019|8|32|3
2019-08-16|2019|8|32|3
2019-08-17|2019|8|32|3
2019-08-18|2019|8|32|3
2019-08-19|2019|8|33|4
2019-08-20|2019|8|33|4
2019-08-21|2019|8|33|4
2019-08-22|2019|8|33|4
2019-08-23|2019|8|33|4
2019-08-24|2019|8|33|4
2019-08-25|2019|8|33|4
2019-08-26|2019|8|34|5
2019-08-27|2019|8|34|5
2019-08-28|2019|8|34|5
2019-08-29|2019|8|34|5
2019-08-30|2019|8|34|5
2019-08-31|2019|8|34|5
2019-09-01|2019|9|34|1
2019-09-02|2019|9|35|2
2019-09-03|2019|9|35|2
2019-09-04|2019|9|35|2
2019-09-05|2019|9|35|2
2019-09-06|2019|9|35|2
2019-09-07|2019|9|35|2
2019-09-08|2019|9|35|2
2019-09-09|2019|9|36|3
2019-09-10|2019|9|36|3
2019-09-11|2019|9|36|3
2019-09-12|2019|9|36|3
2019-09-13|2019|9|36|3
2019-09-14|2019|9|36|3
2019-09-15|2019|9|36|3
2019-09-16|2019|9|37|4
2019-09-17|2019|9|37|4
2019-09-18|2019|9|37|4
2019-09-19|2019|9|37|4
2019-09-20|2019|9|37|4
2019-09-21|2019|9|37|4
2019-09-22|2019|9|37|4
2019-09-23|2019|9|38|5
2019-09-24|2019|9|38|5
2019-09-25|2019|9|38|5
2019-09-26|2019|9|38|5
2019-09-27|2019|9|38|5
2019-09-28|2019|9|38|5
2019-09-29|2019|9|38|5
2019-09-30|2019|9|39|6
2019-10-01|2019|10|39|1
2019-10-02|2019|10|39|1
2019-10-03|2019|10|39|1
2019-10-04|2019|10|39|1
2019-10-05|2019|10|39|1
2019-10-06|2019|10|39|1
2019-10-07|2019|10|40|2
2019-10-08|2019|10|40|2
2019-10-09|2019|10|40|2
2019-10-10|2019|10|40|2
2019-10-11|2019|10|40|2
2019-10-12|2019|10|40|2
2019-10-13|2019|10|40|2
2019-10-14|2019|10|41|3
2019-10-15|2019|10|41|3
2019-10-16|2019|10|41|3
2019-10-17|2019|10|41|3
2019-10-18|2019|10|41|3
2019-10-19|2019|10|41|3
2019-10-20|2019|10|41|3
2019-10-21|2019|10|42|4
2019-10-22|2019|10|42|4
2019-10-23|2019|10|42|4
2019-10-24|2019|10|42|4
2019-10-25|2019|10|42|4
2019-10-26|2019|10|42|4
2019-10-27|2019|10|42|4
2019-10-28|2019|10|43|5
2019-10-29|2019|10|43|5
2019-10-30|2019|10|43|5
2019-10-31|2019|10|43|5
2019-11-01|2019|11|43|1
2019-11-02|2019|11|43|1
2019-11-03|2019|11|43|1
2019-11-04|2019|11|44|2
2019-11-05|2019|11|44|2
2019-11-06|2019|11|44|2
2019-11-07|2019|11|44|2
2019-11-08|2019|11|44|2
2019-11-09|2019|11|44|2
2019-11-10|2019|11|44|2
2019-11-11|2019|11|45|3
2019-11-12|2019|11|45|3
2019-11-13|2019|11|45|3
2019-11-14|2019|11|45|3
2019-11-15|2019|11|45|3
2019-11-16|2019|11|45|3
2019-11-17|2019|11|45|3
2019-11-18|2019|11|46|4
2019-11-19|2019|11|46|4
2019-11-20|2019|11|46|4
2019-11-21|2019|11|46|4
2019-11-22|2019|11|46|4
2019-11-23|2019|11|46|4
2019-11-24|2019|11|46|4
2019-11-25|2019|11|47|5
2019-11-26|2019|11|47|5
2019-11-27|2019|11|47|5
2019-11-28|2019|11|47|5
2019-11-29|2019|11|47|5
2019-11-30|2019|11|47|5
2019-12-01|2019|12|47|1
2019-12-02|2019|12|48|2
2019-12-03|2019|12|48|2
2019-12-04|2019|12|48|2
2019-12-05|2019|12|48|2
2019-12-06|2019|12|48|2
2019-12-07|2019|12|48|2
2019-12-08|2019|12|48|2
2019-12-09|2019|12|49|3
2019-12-10|2019|12|49|3
2019-12-11|2019|12|49|3
2019-12-12|2019|12|49|3
2019-12-13|2019|12|49|3
2019-12-14|2019|12|49|3
2019-12-15|2019|12|49|3
2019-12-16|2019|12|50|4
2019-12-17|2019|12|50|4
2019-12-18|2019|12|50|4
2019-12-19|2019|12|50|4
2019-12-20|2019|12|50|4
2019-12-21|2019|12|50|4
2019-12-22|2019|12|50|4
2019-12-23|2019|12|51|5
2019-12-24|2019|12|51|5
2019-12-25|2019|12|51|5
2019-12-26|2019|12|51|5
2019-12-27|2019|12|51|5
2019-12-28|2019|12|51|5
2019-12-29|2019|12|51|5
2019-12-30|2019|12|52|6
2019-12-31|2019|12|52|6



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to