date-range

Generating a report by date range in rails

How would you go about producing reports by user selected date ranges in a rails app? What are the best date range pickers? edit in response to patrick : I am looking for a bit of both widget and active record advice but what I am really curious about is how to restfully display a date ranged list based on user selected dates. ...

How do you store Date ranges, which are actually timestamps

Java & Oracle both have a timestamp type called Date. Developers tend to manipulate these as if they were calendar dates, which I've seen cause nasty one-off bugs. For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the precision. But if you do that with a date range, (e.g.: 9/29-9/30), the diffe...

SQL Date Range Split

Can you please let me know the SQL to split date ranges when they overlap? Data (sample data with a date range and possibly other columns): Col1 FromDate ToDate 1. 1 1/1/2008 31/12/2010 2. 1 1/1/2009 31/12/2012 3. 1 1/1/2009 31/12/2014 Output: Col1 From Date ToDate 1. 1 1/1/2008 31/12/2008 (from row 1 above) ...

Getting Random Durations within a range in C#

For a random event generator I'm writing I need a simple algorithm to generate random ranges. So, for example: I may say I want 10 random intervals, between 1/1 and 1/7, with no overlap, in the states (1,2,3) where state 1 events add up to 1 day, state 2 events add up to 2 days and state 3 events add up to the rest. Or in code: st...

Getting Dates between a range of dates

Hi All, I need to get all the dates present in the date range using SQL Server 2005 ...

Limiting a date range with exactness in MS SQL / SQL Server 2005

I want to limit a report to return records from Date A through Date B. This is what I have been doing: declare @startDate varchar(20) declare @endDate varchar(20) set @startDate = '01/01/2008' set @endDate = '04/01/2008' -- test what are the start and end dates select min(date),max(date) from view_Inspections where date between @startD...

How to check if a date is in a given range?

If you have a $start_date and $end_date, how can you check if a date given by the user falls within that range? e.g. $start_date = '2009-06-17'; $end_date = '2009-09-05'; $date_from_user = '2009-08-28'; At the moment the dates are strings, would it help to convert them to timestamp integers? ...

How do I find overlaps between two Ruby Runt patterns?

I am developing a Google like calendar on Rails and am using Runt to define the recurrence patterns for creating events. However, the restriction with the calendar is that there cannot be two events for same time slot. So, if i have an event created with event = REDay.new(13,00,15,00) # daily between 1PM to 3 PM Then the application...

SQL date type range not according to spec?

According to MSDN the range for date datatype is January 1, 1753, through December 31, 9999 In SQL2005 the following is interesting: declare @date as datetime SET @date = '1/1/1901 12:00:00 AM' SELECT @date if (isnull(@date,0) = 0) SELECT 'date is null' ELSE SELECT 'date not null' change the date to '1/1/1901 12:00:00 AM' and sudden...

Does anyone know of a good pre-existing javascript date range drop-down?

I'm looking for a javascript drop-down for a date range that allows the user to select start and end dates from a single form field, similar to what exists in the Google Analytics UI. I've found a lot of pre-existing javascript for two separate form fields, or for using a calendar to choose a single date, but nothing that accomplishes...

Find if a given date is in a list of date ranges

I have a list of events that need processing on a constant basis. The process takes care of the event for some time, whereupon it needs processing again. This means that I end up, for each event, with a list of date ranges in which the event was "taken care of" and any gaps mean the event was in an unprocessed state at that time. For thi...

Date Range Intersection Splitting in SQL

I have a SQL Server 2005 database which contains a table called Memberships. The table schema is: PersonID int, Surname nvarchar(30), FirstName nvarchar(30), Description nvarchar(100), StartDate datetime, EndDate datetime I'm currently working on a grid feature which shows a break-down of memberships by person. One of the requirem...

Need help with a MySQL/PHP query involving date ranges

Essentially I need to retrieve some account information from the dbase table where they have a client of the client that has been passed via GET, and the account placement date (dateplaced) is between the start and end dates passed from calendar fields again via GET. The query below returns no rows. I have verified that the SELECT and F...

Build date range...

I have a start date of 20090101 and an end date of 20091130 and I'm trying to build and array of all the months in between, which would look like this: <?php /* ... */ $arrDates['Jan'] = 2009; $arrDates['Feb'] = 2009; $arrDates['Mar'] = 2009; /* ... */ ?> How can I do this? ...

Date Range Query MySQL

I need a query to select data between two dates with today's date as a reference. The database has a datetime field for "start" and a datetime field for "end". $todays_date = date("Y-m-d H:i:s"); $q = "SELECT * FROM news WHERE `end` >= '" . $todays_date . "' AND `start` >= '" . $todays_date . "' ORDER BY id DESC"; The problem is t...

Jquery bassistance: validate that end date is after start date

I am using jquery bassistance validation and need to verify that a start date is after an end date. I am wondering if anyone knows if this functionality exists and if I can add rules to do this or if I have to add a custom check. I am having difficulty finding any examples of this that work with my code which forwards to another functi...

Obtain a date range from a single date

I can do this myself of course, but is there built-in functionality in Ruby, or a library, that would let me do something like this date = Time.now sunday = date.week.first_day saturday = date.week.last_day Thanks ...

SQL join against date ranges?

Consider two tables: Transactions, with amounts in a foreign currency: Date Amount ========= ======= 1/2/2009 1500 2/4/2009 2300 3/15/2009 300 4/17/2009 2200 etc. ExchangeRates, with the value of the primary currency (let's say dollars) in the foreign currency: Date Rate ========= ======= 2/1/2009 ...

T-SQL query to find missing IDs for a date range

Given these tables table Channel -------------- ChannelID int IDENTITY <other irrelevant stuff> table Program -------------- ProgramID int IDENTITY ChannelID int AiringDate datetime <other irrelevant stuff> and this query SELECT C.ChannelID, t.AiringDate FROM Channel C LEFT JOIN ( SELECT distinct ChannelID FROM Pr...

Negative dates in SQLite

Newly compiled SQLite displays a strange behavior concerning the date/time functions. Do you have any idea what is going on and how to fix it? $ date Mon Mar 8 14:52:11 CET 2010 $ ./sqlite3 TEST0 SQLite version 3.6.22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> SELECT d...