date-range

How to check if a date is between date1 and date2 using mysql?

南楼画角 提交于 2019-11-30 15:22:47
I'm trying to write a query that will check today's date against my table columns date1 and date2 in mysql/php.. This is what I'm after: 'events' table: date1 = start date (XXXX-XX-XX) date2 = end date (XXXX-XX-XX) query: select * from events where 2012-01-18 between date1 and date2 (or equal to date1 and date2) But I'm not sure how to go about it.. any help would be appreciated :) EDIT: Maybe I was unclear.. if todays date = '2012-01-18' I need it to find results if today's date is between the date range of date1 and date2.. So date1 may be '2012-01-04' and date2 may be '2012-01-21'.. so if

Create new column based on condition that exists within a rolling date

℡╲_俬逩灬. 提交于 2019-11-30 10:21:29
To make this question more generalized, I believe it could also be rephrased as: Creating a rolling temporally sensitive factor variable . Though an uncommon requirement, this could be utilized for many different data sources. I have a series of non-uniform time data with > 1 record per day for thousands of users. I want to create a new column player_type that keeps track of a rolling 30 day definition of their behavior. The behavior is defined by what games they play; the column 'games' is a factor of gameA, gameB. There are thus three types of behaviors: Exclusively plays GameA - 'A'

SQL group by frequency within a date range

萝らか妹 提交于 2019-11-30 09:20:43
I have a requirement to write a stored procedure that accepts a start date, end date and a frequency (day, week, month, quarter, year) and outputs a result set based on those parameters. Obviously, the simple part is the query by date range, but how do you group by frequency? So if have a set of raw data like this: Date Count --------------------- 11/15/2011 6 12/16/2011 9 12/17/2011 2 12/18/2011 1 12/18/2011 4 And I call my stored proc like this: sp_Report '1/1/2011', '12/31/2011', 'week' I would expect results like this: WeekOf Count --------------------- 11/19/2011 6 12/17/2011 11 12/24

if value is between two numbers

六眼飞鱼酱① 提交于 2019-11-30 08:56:29
问题 I want to be able to test whether a value is within a number range. This is my jQuery code... if ((year < 2099) && (year > 1990)){ return 'good stuff'; } Is there a simpler way to do this in jQuery? For example, is there something like this... if (1990 < year < 2099){ return 'good stuff'; } 回答1: In many languages, the second way will be evaluated from left to right incorrectly with regard to what you want. In C, for instance, 1990 < year will evaluate to 0 or 1, which then becomes 1 < 2099 ,

Crystal Reports Need to Group by Derived Date Range

我的未来我决定 提交于 2019-11-30 08:48:02
问题 Long time listner, first time caller. I'm using Crystal Reports 2010. I have daily trade information that I need to group together if the volume doesn't change. Here's what the data looks like. Trade# BegDate EndDate Volume 1 1/1/2012 1/2/2012 500 1 1/2/2012 1/3/2012 500 1 1/3/2012 1/4/2012 1000 1 1/4/2012 1/5/2012 750 1 1/5/2012 1/6/2012 750 1 1/6/2012 1/7/2012 500 1 1/7/2012 1/8/2012 500 1 1/8/2012 1/9/2012 500 I need it to look like this. Trade# DateRange Volume 1 1/1/2012 - 1/3/2012 500 1

Date range validation

流过昼夜 提交于 2019-11-30 08:44:39
I want to compare two dates (StartDate and EndDate) and check whether one is before the other. The simplest solution is to just do it on the backing bean and "short-circuit" the method. However this validation does not happen concurrently with the other form validations. For example if I have another field that requires validation (besides the dates) and has invalid input, I will only get a message for that specific field. Only if the other fields are valid will I get the date validation based on the backing bean. Anyone have a solution? BalusC However this validation does not happen

How to handle dates in neo4j

荒凉一梦 提交于 2019-11-30 07:25:44
问题 I'm an historian of medieval history and I'm trying to code networks between kings, dukes, popes etc. over a period of time of about 50 years (from 1220 to 1270) in medieval Germany. As I'm not a specialist for graph-databases I'm looking for a possibility to handle dates and date-ranges. Are there any possibilities to handle over a date-range to an edge so that the edges, which represents a relationship, disappears after e.g. 3 years? Are there any possibility to ask for relationships who

Find all date ranges for overlapping start and end dates in R

好久不见. 提交于 2019-11-30 06:01:15
问题 I have a data frame that looks like this: w<-read.table(header=TRUE,text=" start.date end.date 2006-06-26 2006-07-24 2006-07-19 2006-08-16 2007-06-09 2007-07-07 2007-06-24 2007-07-22 2007-07-03 2007-07-31 2007-08-04 2007-09-01 2007-08-07 2007-09-04 2007-09-05 2007-10-03 2007-09-14 2007-10-12 2007-10-19 2007-11-16 2007-11-17 2007-12-15 2008-06-18 2008-07-16 2008-06-28 2008-07-26 2008-07-11 2008-08-08 2008-07-23 2008-08-20") I'm trying to get an output that will combine overlapping start and

Fetching rows added last hour

感情迁移 提交于 2019-11-30 04:40:07
I keep a record of logins in a table. I have columns for id, ip, date and time. From that record of logins I wanna fetch logins made only in the last hour. I'm sweeping through the MySQL docs on time and date functions, but I just can't seem to combine them correctly. Can somebody help me? Make use of the DATE_SUB() and Now() functions: select count(*) as cnt from log where date >= DATE_SUB(NOW(),INTERVAL 1 HOUR); Hope it helps you : ) If you want to implement this into a cronjob, you need to specify the start and end. For example, at 2pm, if you want to get the data for the past hour from 13

MySQL Check if date range is in date range

时间秒杀一切 提交于 2019-11-29 18:24:37
Having trouble making a SQL query for a small booking system, i have a table containing two entries which holds two different dates and a number. Nr DateFrom DateTo ---------------------------- 1 2015-01-01 2015-01-03 2 2015-01-05 2015-01-08 I want to query where i can enter two different dates and only return the number of the date range in the table that doesn't collide with the entered date range. For example if i enter the dates 2015-01-02 and 2015-01-04 it would return Nr 2 and 2015-01-05 and 2015-01-08 would return Nr 1. SELECT * FROM yourTable WHERE DateFrom > @rangeEnd OR DateTo <