date-range

PHP, see if date range is partly within another date range

本秂侑毒 提交于 2020-01-11 08:36:46
问题 I've been looking forever for this, but the answer seems nowhere. Here's the problem: Say, I've got two date ranges. $daterange1 = 2012-04-20 till 2012-04-28 $daterange2 = 2012-04-18 till 2012-05-01 Now, I'd like to know if daterange2 is within daterange1. But, as you can see, daterange2 only partly is within daterange1. Is there any way of getting 3 variables back, something like: 2012-04-18 till 2012-04-20 2012-04-20 till 2012-04-28 2012-04-28 till 2012-05-01 I know it sounds a little vague

Subsetting data.table set by date range in R

谁都会走 提交于 2020-01-09 06:25:34
问题 I have a large dataset in data.table that I'd like to subset by a date range. My data set looks like this: testset <- data.table(date=as.Date(c("2013-07-02","2013-08-03","2013-09-04", "2013-10-05","2013-11-06")), yr = c(2013,2013,2013,2013,2013), mo = c(07,08,09,10,11), da = c(02,03,04,05,06), plant = LETTERS[1:5], product = as.factor(letters[26:22]), rating = runif(25)) I'd like to be able to choose a date range directly from the as.Date column without using the yr , mo , or da columns.

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

不打扰是莪最后的温柔 提交于 2020-01-02 07:33:33
问题 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": {

Get is_purchasable hook working for Woocommerce product variations too

会有一股神秘感。 提交于 2020-01-02 07:29:12
问题 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

% of participants that are retained during six months

拜拜、爱过 提交于 2020-01-02 02:48:07
问题 I am a school teacher very new to MS SQL server. Everyone is suggesting to try this site out. Here goes! I am trying to write queries to test different types of outcome measures for the participation in a academic program. There are several different ways to calculate this outcome measurement I would like to try. The outcome which I am trying to Calculate is: What is the % of participants that are retained during six months of the program? I am testing different ways to define participant and

jquery UI datepicker - disabling date ranges

江枫思渺然 提交于 2020-01-01 16:38:11
问题 I'm struggling to get something working - I'm getting a 'Uncaught TypeError: Cannot read property '0' of undefined' error with the below and I can't figure out why! I'm trying to use the jQuery UI datepicker on a site for a holiday cottage to indicate availability and season (low, high etc). I have a function as a datePicker event to check if there's a booking for a date, and if not, I then go out to check which season we're in (In non-peak season bookings can be made on a Monday or Friday.

jquery UI datepicker - disabling date ranges

十年热恋 提交于 2020-01-01 16:38:08
问题 I'm struggling to get something working - I'm getting a 'Uncaught TypeError: Cannot read property '0' of undefined' error with the below and I can't figure out why! I'm trying to use the jQuery UI datepicker on a site for a holiday cottage to indicate availability and season (low, high etc). I have a function as a datePicker event to check if there's a booking for a date, and if not, I then go out to check which season we're in (In non-peak season bookings can be made on a Monday or Friday.

Split date into several chunks ending by YYYY-12-31

时光毁灭记忆、已成空白 提交于 2020-01-01 14:37:57
问题 df <- data.frame(group = c("a", "a", "b", "b"), start = c("2017-05-01", "2019-04-03", "2011-03-03", "2014-05-07"), end = c("2018-09-01", "2020-04-03", "2012-05-03", "2016-04-02")) Let's say I have the following df: group start end 1 a 2017-05-01 2018-09-01 2 a 2019-04-03 2020-04-03 3 b 2011-03-03 2012-05-03 4 b 2014-05-07 2016-04-02 I want to get it into this format, with each record split into starting date and 31/12 of that and subsequent years: group start end 1 a 2017-05-01 2017-12-31 2 a

Find all intersections of all sets of ranges in PostgreSQL

南笙酒味 提交于 2020-01-01 05:19:12
问题 I'm looking for an efficient way to find all the intersections between sets of timestamp ranges. It needs to work with PostgreSQL 9.2. Let's say the ranges represent the times when a person is available to meet. Each person may have one or more ranges of times when they are available. I want to find all the time periods when a meeting can take place (ie. during which all people are available). This is what I've got so far. It seems to work, but I don't think it's very efficient, since it

How to detect if dates are consecutive in Python?

我是研究僧i 提交于 2019-12-30 06:38:33
问题 I have an access table with a 'Date' field. it has random dates for each record. I've built a script to append all the records into a list and then set the list to filter out only the unique values: dateList = [] # cursor search through each record and append all records in the date # field to a python list for row in rows: dateList.append(row.getValue("DATE_OBSERVATION").strftime('%m-%d-%Y')) # Filter unique values to a set newList = list(set(dateList)) This returns (on my test table): ['07