I have the date of birth of a person and want to calculate the days until his/her next birthday. How to do this in a way to deal with leapyears and other "odd" things?
Using google spreadsheet internal functions:
=IF(DATE(YEAR(TODAY()),MONTH(A2),DAY(A2))>TODAY(),
DATE(YEAR(TODAY()),MONTH(A2),DAY(A2)),
DATE(YEAR(TODAY())+1,MONTH(A2),DAY(A2)))
-TODAY()
where A2 is the cell with the birthday of the person.
The IF at the beginning is for testing if the next birthday is this year or next year.
A slightly shorter neater version using pure sheets functions is:
=DATE(YEAR(A2)+DATEDIF(A2,TODAY(),"y")+1,MONTH(A2),DAY(A2))-TODAY()
This simpler, and uses the DATEDIF(...,"y") to get complete years that have passed and adds one, rather than needing an If around the entire calculation.
Having figured this out working on the problem myself, I then came across the same solution on this site, which includes some more explanation.
following the nice and short version that Jon Egerton posted, here is a small change that returns 0 when the birthday is on the current day (instead of returning 365), and also handles future dates
=DATE(YEAR(A2)+IF(A2<TODAY(),DATEDIF(A2+1,TODAY(),"y")+1,-DATEDIF(TODAY(),A2,"y")),MONTH(A2),DAY(A2))-TODAY()
I found that using WolframAlpha for calculating the days is the most "simple" way to do it. Use the following code:
REGEXEXTRACT(JOIN("";ImportXML(JOIN("";"http://www.wolframalpha.com/input/?i=birthday+";YEAR(A2);"-";MONTH(A2);"-";DAY(A2);"&asynchronous=false&equal=Submit"); "//script")); "(\d+) days until next")
Where A2 is the cell with the birthday of the person.
Related
I'm building a spreadsheet that automatically gets a row added when I get an application on my form. Here is the link to the sheet. As you can see, the first tab is just a list of applications, with the location they've applied for, and the date. The second tab is a daily count for each location, which is eventually sent out as an email each night. I'd like to include weekly numbers, and maybe even an ongoing weekly comparison. e.g. # of apps today, this week (so far), last week, etc.
I'm no expert with this stuff and it's getting a bit over my head possibly. Any ideas on how to get this done smoothly?? Thanks a ton in advance!
Your problem (like many) is primarily a problem with the organization of your raw data.
On a new tab called MK.Help, I've put the following formula in cell A2:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Applications!A2:A&"|"&Applications!S2:S&"|"&FLOOR(Applications!S2:S-2,7)+2&"|"&Applications!B2:R),"|",0,0),"where Col4 is not null and Col2>="&I2))
Then I made a simple table on the right with some fairly straightforward COUNTIFS() that look like this:
=COUNTIFS($C:$C,H$2,$D:$D,$F3)
The layout of the data vertically is what's making the formulas relatively simple for the summary.
I'm trying to create a dynamic dashboard for staff to track the total amount of time they've worked for our program. They fill out a form with start/end time and denote if it's work that's eligible for our program to pay them for it. I'm building a dashboard where they can see how many extended hours they've racked up over the course of the school year because we have limits on how many hours they can earn.
I'm including an editable
copy of my spreadsheet to show what I've got so far... I'd like to add up any durations in column E that have a "Yes" in Column F (which is all of them at the moment) and have that sum sit in cell C5. But all I can get it to do is sum up to zero, and I can visibly see that it should be more than zero. I've tried changing the format of the cell(s) too, but it's still zero.
Any help or ideas are greatly appreciated! And I'm always trying to learn and improve, so if you know how to do this and don't mind explaining to me how the solution works, I'd also really appreciate that so that I can keep getting better at Sheets. :)
Thanks in advance!
This is because the numbers in column J (in Data sheet) are stored as text. Either enter them instantly as numbers or use the helper column where they are converted by the formula e.g. =VALUE(J1)
Played around with it enough that I got it finally!
=SUM(ARRAYFORMULA(if(C8:C="Yes",E8:E-D8:D,0)))
Thanks for helping me troubleshoot and think it through!
First time asking a question here so please forgive me. I am trying to count the number of days in each month between two dates. I have found an answer on here that solves this. However, it breaks down and gives me "0" as a result when the beginning date is in December and the end date is in January.
This answer by Tom Sharpe is the closest that I have been able to get to this answer. Tom's Answer!
I wish I knew how to format code or screenshots on this website. I'm sorry! The link to the question has everything, I just need it to work when the Date Range spans two different years.
Please let me know if I can help.
I just checked the previous answer and it seems to work just fine for me.
=SUMPRODUCT(--(TEXT(ROW(INDIRECT($A2 & ":" & IF($B2="",TODAY(),$B$2))),"mmm")=C$1))
I tweaked it a small amount, making the B2 from the original post an absolute value. I took this under January in cell C2 and handle dragged to fill in to December and everything calculated just fine even over multiple years. My initial thought is that your headings (jan-dec) have something that isn't a 3 letter abbreviation.
I need help calculating the average number of calls I receive per day on Google Sheets. I can use your help.
Specifically, I want to calculate average calls per day [count: timestamps] for weekdays and weekends, respectively.
Here is the link to the Google Sheet: https://docs.google.com/spreadsheets/d/1UnHxSuQeFcKWIYrZxHrKQFJQ0TNekNAGrlvY-CyfYdU/edit?usp=sharing
I have found several links that come close to the solution but nothing that solves it, e.g. http://yogi--anand-consulting.blogspot.com/2013/05/yogifrom-timestamp-column-compute.html
Thank you in advance!
The question has not been asked very well, it important to show your attempts and specifically what you're look for. But none the less:
Create a separate column in call sheet E:E with the formula =weekday(a1) this will convert your date into a day of week number (1 through 7). From that, use sum if =SUMIF(F:F,"<=5") for your weekday, and=SUMIF(F:F,">=6")` for weekwend
My responses are timestamped as soon as anyone submits a survey. I wanted to count those timestamp monthwise.
URL - https://docs.google.com/spreadsheet/ccc?key=0AkpZp6MVqYv1dE5SZjJIODB1WF9nZDR6b1ZJZjFPenc&usp=sharing
I wanted to find out number of positive responses for a particular question (lets say Q1) for a particular month (lets say May)
Column G is not founded out based on the timestamp of Q1, I had asked the user the month, but that's not the correct way to do so, so I have stopped asking the user to enter the month.
First you have to overcome the fact that the timestamp isn't compatible with googles date format. No biggie,... luckily it looks like you have a fixed format ie DD/MM/YYYY. So you can use the LEFT and RIGHT formulas like so =right(left(a2,5),2) This will give you the month in text, ie 05.
Great.
Now for the harder stuff. If you have the newer google spreadsheets, you can simply use countifs to the effect of:
=countifs(arrayformula(right(left(A$2:A,5),2)),"=05",B$2:B,"=Positive")
For each month, replace the "=05" with the the date number you want. You could also make a month lookup chart for all months and questions so that you don't have to modify the formula for each month and quesiton. For this you replace the "=05" with =[cell number containing month number as text] (NOTE: for making a lookup key, you will have to pay close attention to the fact that you are getting TEXT in the formula above vice a number. There is a difference and they are not compatible as-is.)
Let's say you don't have the new google spreadsheets. Then you can use the old sumproduct() and if(). Yes, it is old. See the following:
=sumproduct(arrayformula(if(right(left(A$2:A,5),2)="05",1,0)),arrayformula(if(B$2:B="Positive",1,0)))
Note in both of these, you need to use arrayformula to convert the column with the timestamp into something useable. If you want to make this part easier by removing the parseing functions (LEFT() and RIGHT()) you need to change the timestamp format to be MM/DD/YYYY. Then you can plug in the the MONTH(DATE) formula and it will be done.
Then make a master sheet like so (note my formula has a "'" in it to make it visible for purposes of demonstration, you should remove it.):
Careful inspection might note that the count is wrong. That is because when I imported your timestamps, times like "02/06/2014 ..." were interpreted to mean "February 06" because of google's auto-formatting. In your sheet you will get the correct count using this formula, because of the way your timestamp is auto-populated.
HINT: To make the month a text you need to enter ="05" in the Month column
Please let me know how you make out.