date-range

SQL CHECK constraint to prevent date overlap

I have a table that describes which software versions were installed on a machine at various times: machine_id::integer, version::text, datefrom::timestamp, dateto::timestamp I'd like to do a constraint to ensure that no date ranges overlap, i.e. it is not possible to have multiple software versions installed on a machine at the same ...

SQL: count days in date range?

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? ...

SQL - Query range between two dates (NON-VBA)

I see various topics on this around stack overflow but none that fit the contect of MS-Access... Given a starting date and an ending date, is there a way through SQL to return records for each given month within the time frame? EG: A record has a Start Date of #1/1/2010# and an End Date of #1/31/2010# Running the query against that s...

How do I improve this design for dealing with intersecting date ranges and resolving date range conflicts?

I am working on some code that deals with date ranges. I have pricing activities that have a starting-date and an end-date to set a certain price for that range. There are multiple pricing activities with intersecting date ranges. What I ultimately need is the ability to query valid prices for a date range. I pass in (jan1,jan31) and I ...

C# seconds since specific date

In C# 3.0, how do I get the seconds since 1/1/2010? ...

Selecting a date range where date is not null with Propel

Using Propel I would like to find records which have a date field which is not null and also between a specific range. N.B. Unfortunately, as this is part of a larger query, I cannot utilise a custom SQL query here. For example: I may have records like this: --------------------- | ID | DUE_DATE | --------------------- | 1 | NUL...

Complex query with two tables and multilpe data and price ranges

Let's suppose that I have these tables: [ properties ] id (INT, PK) name (VARCHAR) [ properties_prices ] id (INT, PK) property_id (INT, FK) date_begin (DATE) date_end (DATE) price_per_day (DECIMAL) price_per_week (DECIMAL) price_per_month (DECIMAL) And my visitor runs a search like: List the first 10 (pagination) properties ...

How Do I Loop Through a Date Range in Reverse?

I have a date range that I would like to be able to loop through in reverse. Give the following, how would I accomplish this, the standard Range operator doesn't seem t be working properly. >> sd = Date.parse('2010-03-01') => Mon, 01 Mar 2010 >> ed = Date.parse('2010-03-05') => Fri, 05 Mar 2010 >> (sd..ed).to_a => [Mon, 01 Mar 2010, Tu...

Recursive algorithm for coalescing / collapsing list of dates into ranges.

Given a list of dates 12/07/2010 13/07/2010 14/07/2010 15/07/2010 12/08/2010 13/08/2010 14/08/2010 15/08/2010 19/08/2010 20/08/2010 21/08/2010 I'm looking for pointers towards a recursive pseudocode algorithm (which I can translate into a FileMaker custom function) for producing a list of ranges, i.e. 12/07/2010 to 15/07/2010, 12/08/...

SQL Server 2005 Partition Over Date Range

Is there a way in SQL Server to parition over a date range? I'm looking for something along these lines: SELECT ROW_NUMBER() OVER (PARTITION BY RANGE(DateTimeField) INTERVAL(1)) I want to group rows that are within one day of each other. ...

How Do I Find Common Dates in Two Ranges

I have 2 date ranges, start_date1..end_date1 and start_date2..end_date2, is there an easy "ruby" way to find all the dates that are in both ranges? ...

Django model timerange filtering method

I saw the next two method on 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', ...

Excel pivot table using date column to filter results

I have a Pivot Table which I have entered a date field into the Page Fields area to filter the data in the page. However, I only have the option to select individual dates. I want to use a date range. How can I do this? Or Can I do this? ...

SELECT with MySQL a specific date from a range

Hi Guys, i've two tables Table A: a_id,timemarker (datetime) Table B: b_id,start (datetime), stop(datetime), cat(varchar) table A 149|2010-07-19 07:43:45 150|2010-07-19 08:01:34 151|2010-07-19 07:49:12 table B 565447|2010-07-19 07:30:00|2010-07-19 08:00:00 565448|2010-07-19 08:00:00|2010-07-19 08:20:00 i want select all rows f...

ORACLE SQL Date range intersections

I have a table T1, it contains a NAME value (not unique), and a date range (D1 and D2 which are dates) When NAME are the same, we make a union of the date ranges (e.g. B). But as a result (X), we need to make intersection of all the date ranges Edit: Table T1 NAME | D1 | D2 A | 20100101 | 20101211 B | 20100120 | 20100415 ...

How do I filter dates by a cell formula in an Excel pivot table?

I am attempting to make some reports in Excel using a pivot table of a Sql server view. One of the customer requirements is to be able to filter the reports based on a date range they select, which seems reasonable. The end user process needs to be fairly simple, so my preference is to have a cell for begin date and one for end date and ...

Getting data from a variable number of columns in Excel using Perl with OLE

I am using OLE with Perl to build a few charts in Excel. The data is in four different worksheets depending on which of the four tests it is for. The problem is that I don't know how to set the chart to look at all of the data when I don't know how long it will be. I know to use; $last_col = $sheet -> UsedRange -> Find({What => "*", Se...

Google Calendar API returns events outside date range

I'm trying to select events for the next 2 weeks starting from today's date. The logic used is pretty easy. I get all calendars, then pick one i need to pull events from and supply the date range. I'm pulling dates from the selected calendar however it doesn't look like the date range is applied. Now, i have 2 events scheduled for the f...

Can I use Calendar in a Struts2 Validator Annotation?

Is it possible to use the java.util.Calendar in a Struts2 IntRangeFieldValidator? The following code does not produce any OGNL errors but does not work either. I'm trying to create a validation rule for a year range, min= 1970 and max= current calendar year. @RequiredFieldValidator(message="Year cannot be blank") @IntRangeFieldValidato...

Prevent inserting overlapping date ranges using a SQL trigger

I have a table that simplified looks like this: create table Test ( ValidFrom date not null, ValidTo date not null, check (ValidTo > ValidFrom) ) I would like to write a trigger that prevents inserting values that overlap an existing date range. I've written a trigger that looks like this: create trigger Trigger_Test on Test for i...