date-range

Split date range into one row per month in SQL Server pt2

久未见 提交于 2019-12-11 12:19:55
问题 This question relates to this post: Split date range into one row per month in sql server But I'm new to Stackoverflow and new users are not allowed to place comments to provided solutions.That's why I am now adding this as a new question. The question was this: I have a table with two column called "from_date" and "to_date" The table looks like this: Table (I am not allowed to embed my picture here, so please click the link) I want result like:- from_date || to_date ----------- ------------

Pandas date_range for six-monthly values

冷暖自知 提交于 2019-12-11 10:06:00
问题 I'm trying to create a date range which works in six-month increments backwards from a particular date. So if the end_date is 2020/01/15, then the date before that would be 2019/07/15, then 2019/01/15, etcetera. pandas accepts, say, '6M' as the freq parameter in date_range, but this actually means month-end, so test_range=pd.date_range(periods=10,end=dt.date(2020,1,15),freq='6M') returns DatetimeIndex(['2015-06-30', '2015-12-31', '2016-06-30', '2016-12-31', '2017-06-30', '2017-12-31', '2018

Extjs datefields from to or start end date validations

我的梦境 提交于 2019-12-11 07:59:43
问题 This is a extjs mixin to validate fromdate todate or start end dates in a form. here's the mixin.. (core code was taken from sencha forum :)) Ext.define("AMShiva.mixin.DateRangeValidator", { timerange: function (val, field) { /// <summary> /// This will validate two datefields /// </summary> var me = this; //will be the form, containing datefields var time = field.parseDate(val); if (!time) { return; } if (field.startTimeField && (!this.timeRangeMax || (time.getTime() != this.timeRangeMax

Retrieving row count and returning 0 when no rows

こ雲淡風輕ζ 提交于 2019-12-11 07:56:19
问题 I've written a query to retrieve how many website signups I've had every day: SELECT created, COUNT(id) FROM signups GROUP BY created ORDER BY created desc However, this only retrieves rows for days where people have actually signed up. If nobody has signed up in a day, I would like to return 0 for that day. Is there a way to do this using SQL or will I have to parse through the results using PHP? 回答1: Assuming created to be of type date for lack of information. Postgres provides the

Pandas Remove Elements From DatetimeIndex per Dates in Other DF Column

荒凉一梦 提交于 2019-12-11 06:38:53
问题 Given the following data frame: import pandas as pd df=pd.DataFrame({'A':['a','b','c'], 'first_date':['2015-08-31 00:00:00','2015-08-24 00:00:00','2015-08-25 00:00:00']}) df.first_date=pd.to_datetime(df.first_date) #(dtype='<M8[ns]') df['last_date']=pd.to_datetime('5/6/2016') #(dtype='datetime64[ns]') def fnl(x): l = pd.date_range(x.loc['first_date'], x.loc['last_date'], freq='B') return pd.Series([l]) df['range'] = df.apply(fnl, axis=1) df A first_date last_date range 0 a 2015-08-31 2016-05

ORACLE SQL Range of hours

风流意气都作罢 提交于 2019-12-11 04:57:43
问题 i have a problem, i have a table with 3 columns - date - varchar2 - varchar2 - | date | start_hour | end_hour | I need to make a validation to not overlap hour ranges. For example: | date | start_hour | end_hour | | date1 | 09:00AM | 09:30AM | | date1 | 10:30AM | 11:30AM | | date1 | 01:00PM | 03:00PM | Assuming the date is the same for the 3 rows. What i need is, to no overlap these ranges I cant insert a ranges like this start_hour = 08:00AM and end_hour = 09:20AM, because, a range between

Find subscribers who did not resubscribe within threshold of old subscription

别等时光非礼了梦想. 提交于 2019-12-11 04:29:58
问题 I have a table Subscriptions in PostgreSQL 10.5: id user_id starts_at ends_at -------------------------------- 1 233 02/04/19 03/03/19 2 233 03/04/19 04/03/19 3 296 02/09/19 03/08/19 4 126 02/01/19 02/28/19 5 126 03/01/19 03/31/19 6 922 02/22/19 03/22/19 7 111 01/22/19 02/21/19 8 111 02/22/19 03/21/19 I want to see user_ids who do not have a subscription that starts within 2 days of when their March subscription ended. For users with a subscription that ends in March. Given the table above,

Generate data for range of dates including those that are not present in data

北城余情 提交于 2019-12-11 03:38:39
问题 Here is my table structure and data: CREATE TABLE event ( EventID INT(11) NOT NULL AUTO_INCREMENT, EventDate DATETIME DEFAULT NULL, Description VARCHAR(50) DEFAULT NULL, PRIMARY KEY (EventID) ); INSERT INTO event (EventID, EventDate, Description) VALUES (1, '2011-01-01 00:00:00', 'Event 1'), (2, '2011-03-01 00:00:00', 'Event 2'), (3, '2011-06-01 00:00:00', 'Event 3'), (4, '2011-09-01 00:00:00', 'Event 4'); And this query and output: SELECT * FROM EVENT WHERE EventDate BETWEEN '2011-02-01' AND

How to prevent user from selecting date above end date in react-dates

故事扮演 提交于 2019-12-11 03:18:18
问题 I'm wondering how I could prevent a user from selecting dates above today's date. For example, today is 3.7 so let that be the highest end date a user could select. <DateRangePicker startDate={this.state.startDate} startDateId="startDate" endDate={this.state.endDate} endDateId="endDate" onDatesChange={({ startDate, endDate }) => { this.setState({ startDate, endDate }, () => {}); }} focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null, onFocusChange=

MySQL Select date ranges between data series separated with NULL

纵饮孤独 提交于 2019-12-11 02:09:47
问题 This is a part of solving a more complex problem. There is a table with data: +------------+------+----------+-----------+ | date | data | data_max | data_diff | +------------+------+----------+-----------+ | 2017-01-02 | 2 | 2 | NULL | | 2017-01-03 | 4 | 4 | NULL | | 2017-01-04 | 1 | 4 | -3 | | 2017-01-05 | 3 | 4 | -1 | | 2017-01-06 | 1 | 4 | -3 | | 2017-01-07 | 4 | 4 | NULL | | 2017-01-08 | 5 | 5 | NULL | | 2017-01-09 | -2 | 5 | -7 | | 2017-01-10 | 0 | 5 | -5 | | 2017-01-11 | -5 | 5 | -10 |