date-range

SQL split number over date range

走远了吗. 提交于 2019-12-06 14:11:57
I have a table with, for example this data ID |start_date |end_date |amount ---|------------|-----------|------- a1 |2013-12-01 |2014-03-31 |100 Iwant to have a query that split the dates so I have the amount splitted out over the year like this : ID |org_start_date |org_end_date |new_start_date |new_end_date |amount ---|----------------|---------------|----------------|----------------|------- a1 |2013-12-01 |2014-03-31 |2013-12-01 |2013-12-31 |25 a1 |2013-12-01 |2014-03-31 |2014-01-01 |2014-03-31 |75 The 25 in 2013 is because 2013 has one month and 75 in 2014 because this has 3 months Is

Mongodb Subdocument Date Range Returns Wrong Results

时间秒杀一切 提交于 2019-12-06 12:18:59
问题 first time in Stackoverflow. I'm trying to run a date range query on an array collection but Mongo Shell returning irrelevant documents witch doesn't match my criteria. It doesn't matter i'm doing the query trough PHP drivers, Doctrine Mongodb Query-builder or Mongo Shell. Here is my query: db.deals.find( { "total_sold.created_at": { $gt: new ISODate("2014-03-05T00:00:00Z"), $lt: new ISODate("2014-03-05T23:59:00Z") } }).limit(1).pretty() And here is the result: { "_id" :

Date Range Intersection Splitting in SQL

99封情书 提交于 2019-12-06 08:29:06
问题 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 requirements is to split membership rows where there is an intersection of date ranges. The intersection must be bound by the Surname and FirstName, ie splits only occur

Generating monthly timestamps between two dates in pyspark dataframe

試著忘記壹切 提交于 2019-12-06 06:35:50
问题 I have some DataFrame with "date" column and I'm trying to generate a new DataFrame with all monthly timestamps between the min and max date from the "date" column. One of the solution is below: month_step = 31*60*60*24 min_date, max_date = df.select(min_("date").cast("long"), max_("date").cast("long")).first() df_ts = spark.range( (min_date / month_step) * month_step, ((max_date / month_step) + 1) * month_step, month_step ).select(col("id").cast("timestamp").alias("yearmonth")) df_formatted

c# check if a timespan range is between timespan range and how many hours

半腔热情 提交于 2019-12-06 06:08:45
问题 Assuming I have 3 time ranges: 07:00 - 18:00 18:00 - 23:00 23:00 - 07:00 and the code: public class TimeShift { public TimeSpan Start { get; set; } public TimeSpan End { get; set; } } List<TimeShift> shifts = new List<TimeShift>(); How can I check if every item in the list is between the 3 ranges above and how many hours? For example one TimeShift where: Start: 07:00 End: 23:30 then that means 16.5 hours. For the examples above: Range 1: 11 hours Range 2: 5 hours Range 3: 0.5 hours 回答1: Here

How to get all weekends within date range in C# [closed]

半世苍凉 提交于 2019-12-06 05:51:33
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 5 years ago . I am just wondering if there is a simple way or framework to to get all weekends within date range in C#? Is it possible to do with LINQ as well? Any clue? Thank you! If you make a way to enumerate all days, you can use linq to filter to weekends: IEnumerable<DateTime> GetDaysBetween(DateTime start, DateTime end) { for (DateTime i = start; i < end; i = i.AddDays(1)) { yield

Doing range queries in Mongoose for Hour / Day / Month/ Year

你离开我真会死。 提交于 2019-12-06 02:28:02
问题 Trying to figure out how to do this. Basically I want to sort by Hour / Day / Month / Year of my submissions. Each submission has a created field which contains a Mongoose Date object in the form of "created" : ISODate("2013-03-11T01:49:09.421Z") . Do I need to compare against this in the find() conditions? Here is my current query (I'm wrapping it in a count for pagination purposes FWIW so just ignore that part): getSubmissionCount({}, function(count) { // Sort by the range switch (range) {

Efficiently find overlap of date-time ranges from 2 dataframes

被刻印的时光 ゝ 提交于 2019-12-06 01:43:07
问题 There are some questions out there regarding finding the overlap in date or time ranges (for example). I've used these to solve my problem, but I've ended up with an extremely slow (and not-at-all elegant) solution to my problem. I would really appreciate it if someone has an idea of how to make this faster (and more elegant): The Problem: I've got 2 dataframes, df1 and df2 , each with 2 columns that represent a start time and an end time: >>> df1 datetime_start datetime_end 0 2016-09-11 06

Get is_purchasable hook working for Woocommerce product variations too

百般思念 提交于 2019-12-05 23:34:26
I have made 2 custom product fields - availability - since when/until when. So if the current date is between these set availability dates then product is purchasable, else - it's not. Everything works perfectly however only until I post a product with a variations. Then it's like product variations ignore these custom availability fields/values and still let to add variations to cart even if current date is not between set availability dates. function hide_product_if_unavailable( $is_purchasable, $object ) { $date_from = get_post_meta( $object->get_id(), '_availability_schedule_dates_from' );

ElasticSearch: How to query a date field using a month & date range filter

谁说我不能喝 提交于 2019-12-05 21:37:29
Currently, I already know how to filter a date range from a (timestamp) date field. That's an easy one: "range": { "date": { "gte": "2015-11-01", "lte": "2015-11-30" } } But how to filter dates when you are interested in ranges based on month like gte:"02-22" and lte:"03-21" ? Is this possible? Mapping: PUT dob { "mappings": { "test":{ "properties": { "dob":{ "type": "date", "format": "dateOptionalTime" } } } } } Query: GET /dob/test/_search { "query": { "filtered": { "filter": { "bool": { "must": [ { "range": { "date": { "gte": "02-11", "lte": "03-20" } } }, { "script": { "script": "doc.dob