How to calculate month and any additional days between two dates using google sheet formula? - google-sheets-formula

I want to calculate month between two date and output how month and any additional days by using google sheet
I use this formula to calculate month but i don't know how to calculate any additional days after a complete month.
DATEDIF(AG2,TODAY(),"M")

Quoting this reference of DATEDIF (emphasis mine): https://sheetshelp.com/datedif/
Syntax
=DATEDIF(start_date,end_date,unit)
start_date Date at which to start the calculation
end_date Date at which to end the calculation
unit Type of output. Choices are “Y”, “M”, “D”, “YM”, “YD”, or “MD”.
...
"M" – Number of whole months elapsed between start and end dates
"MD" – Number of days elapsed after the number of months shown with the “M” or “YM” unit. Can’t go higher than 30.
...

Related

DAX comparison operations do not support comparing values of type True/False with values of type Integer

Hi I am looking to complete a vlookup to determine rate costs. I have created a date calendar that contains bank holidays and created a relationship with my main data set. if a job was completed on a sunday or a bank holiday it would be rate 3 or if it mon-fri after 6pm and anytime saturday then rate 2 and all others rate 1. I have tried completing a vlookup howerver it show an error "DAX comparison operations do not support comparing values of type True/False with values of type Integer". i am only learning power BI and any help would be greatly appreciated.
I have columns that show start day, start hour and true/false if it is a bank holiday (Cant seem to add picture)

Summing times in Google sheets

I have a sheet where I record my working hours (this is more for me to remind me to stop working than anything else). For every day, I have three possible shifts - early, normal & late, and I have a formula which will sum up any times put into these columns and give me the daily total hours.
To summarise the duration of time spent working in a day, I use the following formula: =(C41-B41)+(E41-D41)+12+(G41-F41) which is:
early end time minus early start time
normal end time minus normal start time PLUS 12 hours
late end time minus late start time
Which gives me output like this:
What I cannot seem to achieve is, the ability to sum the daily totals into something which shows me the total hours worked over 1-week. If I attempt to sum the daily totals together for the example image shown, I get some wild figure such as 1487:25:00 when formatting as 'Duration' or 23:25:00 when formatted as 'Time'!
All my cells where I record the hours worked are formatted as 'Time'
When using arithmetic operations on date values in Google Sheets, it's important to remember that the internal representation of a date is numeric, and understood as the number of days since January 1, 1970.
What follows from that, is that if you want to add 12 hours to a time duration, you should not write "+12" because that will in fact add 12 days. Instead add "+12/24". In other words, try the following formula instead of the one you are using now:
=(C41-B41)+(E41-D41)+(12/24+G41-F41)

Truncating dates in dc.js

Say I'd like to sum up the number of sales I've made per month, and I have the datetime which sale was made. I also have sales from different years. Is there a convinient way to "truncate" dates so datetimes in the same month and year are equal in dimension? My only solution so far is setting all dates to have day of the month 1.

What is the extra data when I inspect a Date object?

What is the extra data included in a date object? Given the following example:
time = Time.at(1392328830)
# => 2014-02-13 15:00:30 -0700
date = time.to_date
# => #<Date: 2014-02-13 ((2456702j,0s,0n),+0s,2299161j)>
What does all this represent? It's not clear from looking at the Ruby Date documentation.
((2456702j,0s,0n),+0s,2299161j)
What you're seeing is the output from Object.inspect which is a human-readable representation of an object. In the case of the Date class:
From date.rb:
# Return internal object state as a programmer-readable string.
def inspect() format('#<%s: %s,%s,%s>', self.class, #ajd, #of, #sg) end
# Return the date as a human-readable string.
#
# The format used is YYYY-MM-DD.
def to_s() strftime end
The instance variables are:
#ajd is an Astronomical Julian Day Number
#of is an offset or fraction of a day from UTC
#sg is the Day of Calendar Reform
But what do these terms mean?
1. What is an Astronomical Julian Day Number? (#ajd)
For scientific purposes, it is convenient to refer to a date simply as a day count, counting from an arbitrary initial day. The date first chosen for this was January 1, 4713 BCE. A count of days from this date is the Julian *Day* Number or Julian *Date*. This is in local time, and counts from midnight on the initial day. The stricter usage is in UTC, and counts from midday on the initial day. This is referred to in the Date class as the Astronomical *Julian* Day *Number*. In the Date class, the Astronomical Julian Day Number includes fractional days.
2. Offset from what? (#offset)
Time zones are represented as an offset from UTC, as a fraction of a day. This offset is the how much local time is later (or earlier) than UTC. UTC offset 0 is centered on England (also known as GMT). As you travel east, the offset increases until you reach the dateline in the middle of the Pacific Ocean; as you travel west, the offset decreases.
3. What is the Day of Calendar Reform? (#sg)
The Gregorian Calendar was introduced at different times in different regions. The day on which it was introduced for a particular region is the Day *of* Calendar *Reform* for that region. This is abbreviated as sg (for Start of Gregorian calendar) in the Date class.
From what I can tell, the Gregorian Calendar is calendar that self-corrects via leap years.

Calculating day-of-week in years greater than 9999

I was wondering if there are any algorithms that calculate the day of week in years that are greater than the year 9999.
Algorithms such Zeller’s algorithm or this one here gives false results, since they handle only 4 digit year.
Thank you.
You don't actually need a new algorithm. As long as you have one algorithm with a range of 400 years (or more), you can bring any date inside the range of that algorithm. This works because the Gregorian calendar repeats every 400 years (XX/YY/ZZZZ is the same weekday as XX/YY/(ZZZZ+400)).
So, if we assume that you have some algorithm that works for the dates 1/1/1600 to 31/12/1999 (both inclusive), you can calculate the weekday for any date by using (year mod 400)+1600 as the year.
If you don't have a 400-year range starting on 1/1/XXXX (where XXXX mod 400 = 0), you need to manipulate the date slightly different to get the right result (instead of adding 1600 to the year, add X*400, where X is an integer such that some of the dates will be in the range, then add or subtract 400 to the year for those dates that are outside of the range).
http://lxr.linux.no/linux/net/netfilter/xt_time.c for example simply counts it out. To reduce the number of iterations in loops, static tables may be used, as has been done there.

Resources