Determine the number of days a bill range falls into two different date ranges - xls

I am trying to calculate how many days a utility bill falls within two categories (date ranges).i.e. a bill range may be between 16/8/14 - 14/10/14 (total of 60 days incl) and I want to work out how many days fall in the 1/10/2014-31/3/15 season and how many days fall within the 1/4/14-30/9/14 season. It should be 14 and 46 but I am only getting 13 and 44. Any suggestions? thanks

Related

How can we match the length of the Gregorian year and the length of the tropical year?

At present the average length of the Gregorian Year over a period of 400 years is 365.2425 days, calculated as follows.
Average length of the Gregorian Year = (97 x 366 + 303 x 365)/ 400 = 365.2425 days
Since the length of the Tropical year is 365 days 5 hours 48 minutes 46 seconds that is, 365 + 20926/8640 = 365.24219907 days, due to which, there is a gap of 0.0003093 day per year, say 0.00031 day per year in them.
It is not at all difficult to bridge even this gap, by shedding one more leap year over a period of 3226 years, calculated in the following manner.
Supposing it has to be shed over N years — we can, very easily, calculate the value of N, as follows.
N = 1/0.00031 = 3225.8 years, say, 3226 years.
Since it has already covered 438 years since the year 1582 AD obviously, we can synchronise both years by shedding one more leap year over the next “3226 – 438” years, that is, by October 5, 4808.
I would recommend that the International Astronomical Society may take cognisance of this possibility.

Finding peaks in time series with duration condition

I was wondering if anybody could help. If I had a data set containing two columns of date and river flow, how could I obtain the top 100 largest values of river flow, with the condition of having at least a duration of XX days (e.g. 14 days) between each "peak" (i.e. two values which fall within two weeks of each other would only count as 1 peak).
Date
Q
01/01/1990
24
02/01/1990
18
03/01/1990
40
I started by ranking all values and then picking out each peak and manually calculating if the next peak fell outside the 14 day period but I was wondering if this could be performed using a formula. Thanks.

Representing an entire day or week or month as a number like timestamp

How can a day or week or month, essentially a range of time be represented by a single number?
The next interval would represent a number 1 more than the number for the previous interval, just how the next second is 1 more than the previous second, in timestamp representation.
Given a bunch of such numbers, the larger number simply means its representing a time interval afterwards in time, when compared to a number smaller than it.
Just realized if I stick to UTC and represent the day as YYYYMMDD, this becomes a number that I am looking for.
20180420 // 20 april 2018
20180421 // 21 april 2018
20180510 // 10 may 2018
20190101 // 1 jan 2019
This works for representing a day perfectly, I think.
For week, maybe do ceil() of days of current month divided by 7 for representing week as a number W and then using the format: YYYYMMW.
2018043 // 3rd week of april 2018
2018045 // 5th week of april 2018, though may not be the 5th week semantically but representation model works, greater than 4th week of april 2018 and smaller number than 1st week of may 2018
For month, simply YYYYMM works.
I feel so smart right now! 😄

Removing inconsistent observation in r

I have the data frame as I have below. I want to examine all Intake frequencies with "03 Month". My mission is to remove any Intake that is far away from three months by comparing the dates. Intake stands for when a client first register with an agency. 03 Month is three months follow up.
I am running R version 3.3.2 in Window environment.
I have taking the difference between the current date and the previous date in days. However, it is not straight forward to eliminate the observation with less than 90 days and greater than say 100 days as some patient has only intake and no follow up which i will like to keep.
Any help please.
ID DATE FREQ
1 08/09/2014 Intake
1 27/03/2015 Intake
1 01/09/2015 Intake
1 07/12/2015 03 Months
1 18/03/2016 06 Months

Statistical analysis on daily data

I have a number of data points that I am trying to extract a meaningful pattern from (or derive an equation that could then be predictive). I am trying to find a correlation (?) between RANK and DAILY SALES for any given ITEM.
So, for any given item, I have (say) two weeks of daily information, each day consists of a pairing of Inventory, and Rank.
ITEM #1
Monday: 20 in stock (rank 30)
Tuesday: 17 in stock (rank 29)
Wednesday: 14 in stock (rank 31)
The presumption is that 3 items were sold each day, and that selling ~3 a day is roughly what it means to have a rank of ~30.
Given information like this across a wide span (20,000 items, over 2 weeks) of inventory/rank/date pairings, I'd like to derive an equation/method of estimating what the daily sales would be for any given rank.
There's one problem:
The data isn't entirely clean, because -occasionally- the inventory fluctuates upward, either because of re-stocking, or because of returns. So for example, you might see something like
MONDAY: 30 in stock.
TUESDAY: 20 in stock.
WEDNESDAY: 50 in stock.
THURSDAY: 40 in stock.
FRIDAY: 41 in stock.
Indicating that, between Tuesday and wednesday, 30 more were replenished, and on thursday, one was returned.
I am planning to use mean and standard deviation on Daily sales for given rank.
So if any rank given I can predict the daily sales based on mean and standard deviation values.
Is this correct approach? IS there any better approach for this scenario
Sounds like this could be a good read for you, fpp
It provides an introduction to timeseries forecasting. Timeseries forecasting
has a lot of nuance so it can trip people up pretty easily. Some of the issues
you have already noted (e.g. seasonality). Others pertain to the statistical
properties of such series of data. Take a look through this and

Resources