date-range

How to identify the maximum number of overlapping date ranges?

亡梦爱人 提交于 2019-12-02 06:41:58
This question might be similar to: Determine Whether Two Date Ranges Overlap Multiple Date range comparison for overlap: how to do it efficiently? But, how can I get the maximum number of overlapping date ranges? (preferably in C#) Example: (from - to) 01/01/2012 - 10/01/2012 03/01/2012 - 08/01/2012 09/01/2012 - 15/01/2012 11/01/2012 - 20/01/2012 12/01/2012 - 14/01/2012 Result = 3 maximum overlapping date ranges Solution : Possible implementation of the solution proposed by @AakashM List<Tuple<DateTime, int>> myTupleList = new List<Tuple<DateTime, int>>(); foreach (DataRow row in objDS.Tables

Insert multiple records with a date range in MS Access

梦想的初衷 提交于 2019-12-02 05:44:49
hoping someone can help? I'm fairly new to Access 2016 and have been tasked with building a very simple booking system for our school's breakfast and after school clubs. I have a table with a list of Children (primary key is ChildID), another table (CLUBS) lists the 5 clubs available, and a third table (BOOKINGS) connects the children to the clubs (ChildID, ClubID, DateRequested) I have a simple form that enables me to select a child's name from a drop down box, then from a list choose a club, then enter the date required. This saves the record to the Bookings table. This works fine, however

How to create a 'past 3 months' time period in Google Data Studio

让人想犯罪 __ 提交于 2019-12-02 04:43:00
I'm trying to have my line chart show data for the past 3 months. GDS has a 'last quarter' date range, but this shows me Q1, Q2, Q3, or Q4. What I need is the data for the past 3 full months (not counting the current month). I tried creating a calculated field but the documentation isn't proving very useful for the matter at hand. eg. If the current date is Feb-20, I want to show data from 'Nov 1 - Jan 31'. Also need to compare to same period from last year. Can anyone help? Thanks in advance! You can use the option "advanced" in the date dropdown and set the start date to today minus 3 months

compute sum of values associated with overlapping date ranges

余生长醉 提交于 2019-12-02 04:02:37
I have a simple table of date ranges each with an associated number of hours per week: CREATE TABLE tmp_ranges ( id SERIAL PRIMARY KEY, rng daterange, hrs_per_week INT ); And some values from which I would like to compute (ie aggregate) the sum of hours per week for the overlapping/intersecting date ranges: INSERT INTO tmp_ranges (rng, hrs_per_week) VALUES ('[2014-03-15, 2014-06-28]', 9), ('[2014-04-18, 2014-07-15]', 2), ('[2014-06-03, 2014-09-12]', 9), ('[2014-10-03, 2014-11-14]', 6); Graphically (and hopefully this reveals more than it obscures), the solution looks as follows: hrs/wk T T` 9

Django model timerange filtering method

时光怂恿深爱的人放手 提交于 2019-12-02 03:36:15
问题 I saw the next two methods in an old question here but it is not clear for me what is the difference between: {'date_time_field__range': (datetime.datetime.combine(date, datetime.time.min), datetime.datetime.combine(date, datetime.time.max))} and YourModel.objects.filter(datetime_published__year='2008', datetime_published__month='03', datetime_published__day='27') 回答1: Was confused about this myself, but I think I've worked it out :-D I found the documentation about the range lookup option

Count days in date range?

半城伤御伤魂 提交于 2019-12-02 03:28:51
问题 I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales = 'YES' AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31' I am selected from a date range. Is there a way to also get the total days in the date range? 回答1: Not really clear if you are looking for DATEDIFF('2010-03-31', '2010-01-01') or COUNT(DISTINCT daily_individual_racking_date) 回答2: What exactly are you trying to count? The total number of distinct values of daily

Django model timerange filtering method

北城余情 提交于 2019-12-02 01:24:53
I saw the next two methods in an old question here but it is not clear for me what is the difference between: {'date_time_field__range': (datetime.datetime.combine(date, datetime.time.min), datetime.datetime.combine(date, datetime.time.max))} and YourModel.objects.filter(datetime_published__year='2008', datetime_published__month='03', datetime_published__day='27') Was confused about this myself, but I think I've worked it out :-D I found the documentation about the range lookup option very helpful. When you do: YourModel.objects.filter(datetime_published__year='2008', datetime_published__month

Count days in date range?

我的梦境 提交于 2019-12-02 01:22:15
I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales = 'YES' AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31' I am selected from a date range. Is there a way to also get the total days in the date range? Not really clear if you are looking for DATEDIFF('2010-03-31', '2010-01-01') or COUNT(DISTINCT daily_individual_racking_date) What exactly are you trying to count? The total number of distinct values of daily_individual_tracking_date? Do you need it in the same query as the count(*) query? You can use the MySQL datediff function

Left outer join acting like inner join

跟風遠走 提交于 2019-12-02 00:41:41
Summary My goal is to find every user who has ever been assigned to a task, and then generate some statistics over a particular date range, and associate the stats with the original set of users. When no statistics exist for a particular user, I want a row in the output for the user but NULL values for the stats. I have a complex SQL query that looks like this (actual query at the bottom): SELECT user_name, changeday, project_name sum(hour_delta) AS hours, FROM ( … ) tasked_users LEFT OUTER JOIN ( … ) a ON tasked_users.id=a.assignee_id WHERE (changeday IS NULL) OR (changeday >= … AND changeday

Create list with first and last day of month for given period

独自空忆成欢 提交于 2019-12-02 00:37:27
问题 I have to generate a list with two columns of day intervals for every month in a specific period. First column must be the first day of month and the second column the last day of month. Example: Start date: 2014-01-01 End date: 2014-06-30 The result should be in two columns: 1. 2014-01-01 | 2014-01-31 2. 2014-02-01 | 2014-02-28 3. 2014-03-01 | 2014-03-31 4. 2014-04-01 | 2014-04-30 5. 2014-05-01 | 2014-05-31 6. 2014-06-01 | 2014-06-30 I have two functions that get the first and last day from