I need to fill column with date incremented by one day for the whole year. How to make it in automatic way?
UPD:
I have 2017-06-12 in B60
If I add 24 hrs I still have previous day. Why?
=B60+time(24,0,0)
If I add 23 hrs - day increase works.
=B60+time(23,0,0)
if
The reason why
=B60+TIME(24,0,0)
doesn't work is that times between 00:00:00 and 23:59:59 are stored as values between 0 and (nearly) 1. The maximum value that you can get from the TIME function is =TIME(23,59,59) - if you put =TIME(24,0,0) then it rolls back to 00:00:00 which is stored as zero. If you add zero to anything (including a date) you just get the original value.
You need to put in the value for a day which is just 1 so the formula should be
=B60+1
See Time Function Documentation
Just drag down the first cell.
A1 = start date:
5/29/2017
A2 = number of days:
365
A4 = formula:
=ARRAYFORMULA(ROW(INDIRECT("a1:a"&A2))+A1)
From here and here:
Put in A1 the value 30/12/2012 08:15:00
Put in A2 the formula: =A1+time(23;59;59)
Copy the formula in A2 down as far as you need.
Related
When I use the formula below the results of the EOMONTH function
returns the start of the next month for any month with 30 days instead of the last day of the specified month. The month and years are correct, so I'm pretty sure it's EOMONTH when used in another function.
For example,the results in B3 should be "11/31/1965" but it returns "12/1/1965".
=DATE(YEAR(B2),MONTH(B2)+6,DAY(TEXT(EOMONTH(MONTH(B2)+6,0))))
I have tried subtracting a day, but it returns the end-of-month -1 for months with 31 days (30). So I have the same problem in the other case.
I have also used IFS() to account for months with 30 days, and it miscalculates the date the same way.
=IFS( MONTH(B2)+6 = 4,DATE(YEAR(B2),MONTH(B2)+6,DAY(EOMONTH(MONTH(B2)+6,0))-2) ,
MONTH(B2)+6 =
6,DATE(YEAR(B2),MONTH(B2)+6,DAY(EOMONTH(MONTH(B2)+6,0))-2) ,
MONTH(B2)+6 =
9,DATE(YEAR(B2),MONTH(B2)+6,DAY(EOMONTH(MONTH(B2)+6,0))-2) ,
MONTH(B2)+6 =
11,DATE(YEAR(B2),MONTH(B2)+6,DAY(EOMONTH(MONTH(B2)+6,0))-2) ,
TRUE ,DATE(YEAR(B2),MONTH(B2)+6,DAY(EOMONTH(MONTH(B2)+6,0)) ) )
The EOMONTH function by itself where I just pass in the date as a string works correctly (column F).
Any Idea on what I'm doing wrong?
Thanks in advance.
Yes, as #player0 has explained, you can't just add something to a month and feed it into eomonth. Try putting
=eomonth(month(B2)+6,0)
into B3 (formatted as a date).
You get
1/31/1900
Why? month(b2)+6 gives 11 (which is just a number). Dates in google sheets are represented as days since 12/31/1899. So 11 formatted as a date gives 1/11/1900. Applying eomonth to that gives the last day of January 1900, which is the 31st. Feeding that into your formula would give 11/31/65, but that date doesn't exist, so you get 12/1/65.
If you want to go forward 6 months and then get the last day of the month, you need
=eomonth(date(year(B2),month(B2)+6,1),0)
You can also use the Edate function, which does not roll over into the first day of the next month:
=eomonth(edate(B2,6),0)
EOMONTH does not understand MONTH. instead, it converts it into date. to use EOMONTH you need to supply it with valid date
=EOMONTH(B2, 0)
I am trying to figure if the following can be done. If there are duplicate names in the B column then it will see if the date and time were within 24 hours of each other in the A column, if so it will highlight the cell yellow.
Currently, the formula I have will only highlight if it was on the same date. Is there a way I can add to the formula to all take into account time? So that if one response is on 5/20/20 at 17:00 and the next duplicate name is at 5/21/20 at 16:00 then the cell would be highlighted.
Here is the formula I am using the just highlights if it is within the same date:
=ARRAYFORMULA(COUNTIFS(B:B, B2, DATEVALUE(A:A), DATEVALUE(A2))>1)
I am not sure if something like this is possible. I am guessing that the formula would have to compare both datevalue and timevalue. Any help would be appreciated.
Instead of DATEVALUE you can use TO_PURE_NUMBER
This will return you the number of days from January 1, 1900 including the fraction for past hours and minutes opposed to DATEVALUE that rounds the value down to an integral day number.
Sample:
This allows you to calculate the real difference time between your timestamp.
For example like this:
=ARRAYFORMULA(or(COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2)-1, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2))>0,COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2)+1,TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2))>0))
Time started time end Duration
6:02:53 PM 6:11:07 PM 0:08:13
6:11:22 PM 6:20:33 PM 0:09:11
6:20:48 PM 6:32:21 PM 0:11:34
6:32:44 PM 6:39:04 PM 0:06:20
6:39:28 PM 7:00:41 PM 0:21:13
7:01:00 PM 7:09:16 PM 0:08:16
7:09:40 PM 7:16:03 PM 0:06:23
7:16:03 PM 7:24:21 PM 0:08:17
7:24:45 PM 7:30:57 PM 0:06:12
7:31:27 PM 7:37:21 PM 0:05:54
7:37:21 PM 7:44:06 PM 0:06:45
I want sum of all duration entries in x hours x minutes x seconds like i have more then 1000 rows of duration when i try to use =SUM(C2:C100) I am not getting sum of total duration after sum of 24:00:00 24 hours it starts from 00:00:00
for example sum of total duration gets 24:00:00 between range of c1:c8 it will start from 00:00:00 from c9: next range kindly assist me how to overcome this issue
try:
=ARRAYFORMULA(TEXT(SUM(IFERROR(TIMEVALUE(C:C))), "[h]:mm:ss"))
spreadsheet demo
Wherever you put the =SUM(), Select that cell and do Format>Number>More Formats>Custom Number formatting, and put the same formatting that Player0 put in his answer:
What worked for me to resolve a similar problem was a suggestion by user ttarchala in Google Sheets Query multi condition sum of time duration.
I used N() function as he said, and my final formula for the duration is:
=IF(To<>"", N(To-From+(To<From))*24, "")
with To and From being Named ranges for End Time and Start Time respectively.
N() function converts the time delta into a number. Multiplied by 24, this gives the hours in decimal format, such as 2 hours 30 minutes = 2.5 hours.
From there on, there is no problem with using the built-in Sum function to calculate the total duration as a decimal. Such as, the total duration of 27 hrs 10 minutes is shown as 27.16. This sufficed for my purposes.
Time delta is calculated using a formula from https://webapps.stackexchange.com/questions/104829/calculate-time-difference-between-times-past-midnight to take into account past-midnight differences.
And the first condition, To<>"", makes sure the formula is not showing in empty cells. As soon as the End Time is filled into "To" column, the decimal duration is calculated. Then it can be used in the regular Sum function.
This seemed shorter and easier than the formulas suggested above so I am sharing it in the hopes it may help someone else. Using thus formula, I just added up the Sum of time I spent looking for this solution: 3.34 hours :)
It's a formatting problem. You formatted your reply as HH:MM:SS, therefore the number displayed is not showing the date, which would have been incremented by one. If you multiply your sum by 24, and then format the result as a pure number, you will get a number that goes above 24, and will show you the number of hours, and its decimals. If you use those hours in further calculations, the result will be correct.
In cell C1, use the formula
=IF((B1-A1)>=0, B1-A1, 1+B1-A1)
Explanation: the problem is durations that exceed the 24 hour limit, as you say.
Google Sheets has become a bit deceptive here, as it will show the correct duration for the individual time interval, but if you SUM over it, it will actually deduct the value!
A B C
23:39 1:10 1:31
When you SUM then Google Sheets will see the value in cell C1 as if it was the beginning of the same day as the time in A1. So when you in C1 do =B1-A1 then it will register as a negative duration! But it won't show up as that!
In C1 use this formula, =IF((B1-A1)>=0, B1-A1, 1+B1-A1) for individual cells in column C, when you see that cells in column B has exceeded the 24-hour limit once. The duration in C1 should still show 1:31, but now the result when doing SUM over a range of cells in column C, like =SUM(C1:C2), will now show the correct and strictly additive sum. You can safely copy this formula to all cells in column C.
PS: cells in all of the columns can have Automatic or no formatting (which I think defaults to Automatic), if your time inputs look like the above. So you don't need to format all of those cells to Time or Duration. BUT remember to format the SUM cell to Format -> Number -> Duration.
PPS: if you are manually inputting the times (for for instance time tracking), then the easiest way to keep the much simpler =B1-A1 formula is to split the time up into two rows, like this:
A B C
23:39 0:00 0:21
0:00 1:10 1:10
Then the SUM of cells in column C still becomes 1:31.
I have a column with month day numbers, so 20 means the 20th of the month.
I want to know how to check if a value in this column, say 20 is more than or less than today's month day.
I would use conditional formatting to color the cell in red if that day had not passed already.
What I tried to do was set a cell with today's date:
=TODAY()
Then based on this calculate if the month day was less than or greater by using this:
=DATEDIF(F2, "MD")
I was hoping this wold return a number which I could then do a compare with but this is wrong and I am not sure if what I want to do is even possible.
I have read through the documentation and Stackoverflow but I cannot find any close examples.
Thank you.
If you want to check the day of the month you need to extract exactly that.
If your date is in Cell A1 and your threshold (20) in A2 the conditional formatting formula to check if the date has not passed yet would then go:
=DAY(A1) < A2
I believe the issue I am having now should be much easier in MS Excel. However, since my company uses Google Spreadsheet so I have to figure out a way.
Basically, I have a cell that contains a date value like "12/19/11", and I have another cell contains a value like "DT 30". The task assigned to me is to add the value 30(days) to the date, so the result should be "1/19/2012".
I did some trying in Google Spreadsheet, I have two questions. The first is to how to extract the numeric value "30" out of the string "DT 30", the second question is that, there seems to be no date add function built in Google Docs.
Could any experts offer some suggestions?
I like to keep it simple. If A1 holds the date and B1 holds the number of months to add, then
=date(year(A1),month(A1)+B1,day(A1))
would calculate the required result. The same way could be used for days or years
To extract a numeric value out of your string you can use these 2 functions (Assuming you have your value in cell 'A1'):
=VALUE(REGEXEXTRACT(A1, "\d+"))
This will get you a numeric value.
I've found no date add function in docs, but you can convert your date into internal date number and then add days number (If your value is in cell 'A2'):
=DATEVALUE(A2) + 30
I hope this will help.
You can just add the number to the cell with the date.
so if A1: 12/3/2012 and A2: =A1+7 then A2 would display 12/10/2012
You can use the DATE(Year;Month;Day) to make operations on date:
Examples:
=DATE(2013;3;8 + 30) give the result... 7 april 2013 !
=DATE(2013;3 + 15; 8) give the result... 8 june 2014 !
It's very surprising but it works...
The direct use of EDATE(Start_date, months) do the job of ADDDate.
Example:
Consider A1 = 20/08/2012 and A2 = 3
=edate(A1; A2)
Would calculate 20/11/2012
PS: dd/mm/yyyy format in my example
As with #kidbrax's answer, you can use the + to add days. To get this to work I had to explicitly declare my cell data as being a date:
A1: =DATE(2014, 03, 28)
A2: =A1+1
Value of A2 is now 29th March 2014
Using pretty much the same approach as used by Burnash, for the final result you can use ...
=regexextract(A1,"[0-9]+")+A2
where A1 houses the string with text and number
and A2 houses the date of interest
what's wrong with simple add and convert back?
if A1 is a date field, and A2 hold the number of days to add:
=TO_DATE((DATEVALUE(A1)+A2)
=TO_DATE(TO_PURE_NUMBER(Insert Date cell, i.e. AM4)+[how many days to add in numbers, e.g. 3 days])
Looks like in practice:
=TO_DATE(TO_PURE_NUMBER(AM4)+3)
Essentially you are converting the date into a pure number and back into a date again.
In a fresh spreadsheet (US locale) with 12/19/11 in A1 and DT 30 in B1 then:
=A1+right(B1,2)
in say C1 returns 1/18/12.
As a string function RIGHT returns Text but that can be coerced into a number when adding. In adding a number to dates unity is treated as one day. Within (very wide) limits, months and even years are adjusted automatically.