Google Sheets: Automatically Increment Date by 1 Month - date

I am currently using a budget sheet that automatically updates date cells to the next "payment" date for a bill. As an example:
=VALUE("2019-03-08")+14*FLOOR((NOW()-VALUE("2019-03-08"))/14)
The cell starts with a date and it then updates every 14 days to the new date. This shows me a cell that has the date of the biweekly payment that is due. In the above example, the cell shows the value of "2019-03-08" until 2 weeks have passed. Once 14 days have passed, the cell will automatically upload to "2019-03-22". This automation will continue forever in 14-day increments. The date displayed in the cell will always update automatically to the next 14-day date. This helps me display the exact due date of a biweekly payment without updating the cell.
I want to do the same thing for a monthly payment, but using a day count of 30 is not very accurate. Is there a way to modify this method to let me update the date automatically to the 24th of the month, every month, on that day. So I start with 2/24/2019 and when 3/24/2019 hits, the cell updates to that date, and so on. The reason this is not accurate is that the months are not all 30 day periods. February is 28 days and some are 31 days. I want the cell to increment in 1 month periods in the same way that the above formula updates in 14-day increments. As an example: The date will display "2/24/2019" until the same day on the next month occurs, then the cell will update to "3/24/2019". This process will continue forever with 4/24/2019, 5/24/2019, etc. It will continue with the year as well, so 12/24/2019 will change automatically to 01/24/2020.
UPDATE: Updated the description with examples of how the behavior works and what I am looking for...

It's much simpler than this. Use the EDATE function (e.g.):
=EDATE(A1,1)
Where A1 is your starting date and 1 is the number of months you which to increment by. See https://support.google.com/docs/answer/3092974?hl=en for more details.

this formula will increase the month every 24th and accounts for year change as well
=IF(DAY(TODAY())>=24,
DATE(YEAR(TODAY()), MONTH(TODAY())+1, 24),
DATE(YEAR(TODAY()), MONTH(TODAY()), 24))

paste where you need and drag down:
=VALUE("2019-"&ROW(A3)&"-08")+14*FLOOR((NOW()-VALUE("2019-"&ROW(A3)&"-08"))/14)

Related

Why is Date.getMinutes() returning 2 for the time 4:00 PM?

I'm creating a customized function that does some calculations for a given time.
When a time is entered in a cell, for example 4:00 PM, this is automatically converted into a date, in this case 12/30/1899 16:00:00 and when the function getTheMinutes() is called, it returns 2 instead of 0.
function getTheMinutes(dateTime){
return dateTime.getMinutes();
}
The behavior of the function is different if it's used for a most recent date like 5/1/2019 16:00:00.
I want the user to be able to just write a time in a cell then use the customized function in another cell. Please let me know your thoughts.
Now that you have indicated the time zone for your spreadsheet I can confirm what #RobG deduced almost a day ago, which is that Guatemala adjusted its difference relative to UTC. Something you have confirmed is treated as by two minutes with effect from October 5, 1918.
More specifically, the adjustment was of 2 minutes and 4 seconds and effective from 03:00 that day:
(Source IANA Version 2019b file northamerica.)
There have been very many such minor adjustments around the world over the years (even between towns in the same country) and adjustments continue, though usually of a whole hour – between 'standard' and Summer time. Sheets has very properly recognised that "normal arithmetic" 'does not work' across such a transition and while noon yesterday to noon today for example is normally, for any one specific location, a difference of 24 hours it is often 23 hours or 25 hours on the day that clocks go forward/back.
And the moral of the story is to beware of obliging Sheets to assume, for want of a specific date, that is has the index number 0 - i.e. is December 30, 1899.
I made some testing, and I found out that the formula is giving a wrong result any minute before 10/5/1918 0:03:00, from that DateTime on, the formula is working as expected.
Here is my sheet https://docs.google.com/spreadsheets/d/1psm8_GJYRczO53TILJCOzo0p4GpnS-ooiGWqOJrC8ZU/edit?usp=sharing
I would need to do a date validation in my customized formula to make it useful. I don't know why google sheets is choosing that date as default when just a time is typed in a cell, I think it should be improved.

SAS start and end date from consecutive run

I have a dataset of customers buying items in multiple batches of consecutive days over the year e.g. Customer A buys on the 1st of January, the 2nd of January and the 3rd of January, stops, then buys again on the 1st of February, the 2nd of February and the 3rd of February.
I'm looking to capture the first and last date of each consecutive batch for each customer (so the usual MIN / MAX will miss out of batches in between dates).
I've experimented with RETAIN and LAG and I'm getting close but its not quite what I want.
How do I create a query that will display two rows for Customer A? i.e. row 1 showing start date of the 1st of January and end date of the 3rd of January; row 2 showing start date of the 1st of February and end date of the 3rd of February.
You are asking to group the values based on the presence of a gap between the dates. So test for that and create a new group number variable. Then you can use that new grouping variable in your analysis.
data want ;
set have ;
by id date;
dif_days = dif(sales_date);
if first.id then group=1;
else if dif_days > 1 then group+1;
run;
You can adjust the number of days in the last IF statement to adjust how large of a gap you want to allow and still consider the events as part of the same group.

Tableau: time series chart displaying last day of month instead of first

In any time series chart, it looks like Tableau defaults to the first day of the month on the tick marks.
Is there a way for Tableau to show the last day of the month instead?
You can sort of force it by going into "Edit Axis", starting it on a month end, and 1 as the monthly interval. However, this is not a dynamic process and would require that I update this every time I had new data.
Anyone have any ideas? Thank you!
If in your data series you want each data point to represent the whole month, and you just want to label it with the last date of that month, then this workaround might work:
use calculated field to coerce all dates in the month to the last date of that month: DATEADD('day',-1,DATEADD('month',1,DATETRUNC('month',[Order Date])))
use this field as date in your time series
use 'More -> Custom -> Month / Day /Year' as display option for this field

Matlab- Changing uniques date code values to more manageable data

I have a variable called sentDate which stores the month and day from Nov 27th - Dec 6th.Each day has a number of sentiment ratings that it represents therefore I need to assign unique day codes to each day so I can perform...
allSents(dayCodes==1)
So far I have managed to assign day codes using...
[a,b,dayCodes]=unique(sentDate);
[d,e,allSents]=unique(sentiment);
However the day codes take the last digit on the date e.g 27th becomes 7, 28th becomes 8, etc. I need it so the day codes start from 1 and increase for each day until the 6th of December, therefore 1-11.
Any idea on how I may do this ?
have you tried the datenum function? then subtract off whatever offset to give the appropriate start day number.
For those who may have a similar problem, by specifying stable in as a parameter e.g
[a,b,dayCodes]=unique(sentDate,'stable');
Will specify the daycodes in the same order as in sentDate.

Creating Dynamic Date Column Headings in Cross Tab for Business Objects

BO Version: 12.1.0 on Infoview,
O/S: W7
I am creating a report in infoview, which is a cross-tab. I have departments on the row side and for the column I want to have all Saturday dates dynamically displayed, and this is dependent on the date prompt values I put in to the report when I run it.
So if I put in for the prompts Dec the 08th 2013 to Jan the 04th 2014 I should see 4 Saturday dates (14th/21st/28th/04th) along the column headers.
I started off using a variable and using the function relativedate, which gave me all the dates I wanted:
=RelativeDate(LastDayOfWeek([Query 1].[Episode End Date]);-1)
but because I used -1 to get the Saturday date it was giving me the Saturday before the earliest prompt date, so I was getting these dates instead:
(07th/14th/21st/28th/04th)
Is there a way I can get these dates but ignore the previous day (the 7th) before the start prompt date?
I want to have this dynamic so that if I put a date range in it shows me all the saturday dates within that range along the top of the report regardless of the date range period.
Andrew
The reason you're having trouble is that WebI (being ISO compliant) considers a week to run from Monday to Sunday, but your reporting week ends on Saturday.
So, I would approach it this way:
=RelativeDate(
LastDayOfWeek(
RelativeDate([Query 1].[Episode End Date];1)
)
;-1)
If we evaluate some dates with this logic, we'll see the desired result:
Testing 12/8 (Sunday):
Add one day = 12/9
Get Last Day Of Week = 12/15
Subtract one day = 12/14
Testing 12/12 (Thursday)
Add one day = 12/13
Get Last Day Of Week = 12/15
Subtract one day = 12/14
Testing 12/14 (Saturday)
Add one day = 12/15
Get Last Day Of Week = 12/15
Subtract one day = 12/14
I'm at home and don't have access to WebI right now, so I can't test this myself, but the logic should be sound.