Whenever I type a function into Microsoft Excel 2013, a small hint box is displayed which lists the function's arguments.
For some reason, this hint box doesn't appear when using DATEDIF(). I can't find it listed anywhere on the formula tab, nor am I shown any reminder of what arguments to use. Excel won't even autocomplete the formula name while typing.
Returns number of days between Nov 15-Nov 20
The formula works as expected once entered, but it's difficult to use properly when I need to have the arguments memorized.
Why isn't Excel displaying argument hints for DATEDIF()?
DATEDIF is an undocumented function in Excel
From Office Support:
Excel provides the DATEDIF function in order to support older
workbooks from Lotus 1-2-3. The DATEDIF function may calculate
incorrect results under certain scenarios.
From My Online Training Hub
For some reason Microsoft [doesn't] think the DATEDIF function is worthy
of any documentation since Excel 2000. In fact they say they only
include it in recent versions for backward compatibility.
From Happy LTD
Microsoft no longer supports this function in Excel. You can still use
it, but you don’t get any help with it.
A suggestion is: UDF replacement for Excel's DATEDIF function
Also visit:
Do not use the undocumented DATEDIF function
Introduction To The DATEDIF Function
The "DATEDIF" function has its origins in "LOTUS 1-2-3", and apparently Excel provides it for compatibility purposes. It has been available since Excel 5, but Excel 2000 is the only version that ever documented it in its Help system.
The function takes 3 arguments: start_date, end_date, and a code that represents the time unit of interest. I am including cells A1 & A2 for the purposes of the example. Substitute the cells you need to use.
The following code is an example:
=DATEDIF(A1, A2, "y") You must enclose the code in quotation marks.
The following table lists the codes available with the returns.
"y" The number of complete years in the period.
"m" The number of complete months in the period.
"d" The number of days in the period.
"md" The difference in days between the start_date and end_date. the
months
and years are ignored.
"ym" The difference in months between the start_date and end_date.
the days
and years are ignored.
"yd" The difference in days between the start_date and end_date. The
years
of the date are ignored.
NOTE, the start_date must be earlier than the end_date or the function will return an error.
Related
I have a date 2020-01-30 (yyyy-MM-dd).
When I change the column format to Text it is getting converted to 43860.
I want to know how it is making it to 43860?
I came to know from Microsoft community that its a difference between 01-01-1900 to the written date. Then is should be 43858 . Why its 43860 ?
In Excel Date/Times are Doubles. It is the number of days since 1899-12-31. If you want to have text instead of a true date you will need to convert it by using the TEXT() Function on the worksheet or Format() in VBA.
There is an included error so that Excel could be compatible with Lotus 1-2-3. It assumes that 1900 was a leap year, which it was not. See: https://www.myonlinetraininghub.com/excel-date-and-time
=TEXT(A1,"yyyy-MM-dd")
Cited many times on SO. It's the number of days between Jan-1-1900 (or 1904) and the given date. This is what allows you to do math on dates.
https://support.microsoft.com/en-us/office/date-systems-in-excel-e7fe7167-48a9-4b96-bb53-5612a800b487
I am trying to add a new column in Spotfire so I can get the age of the person in years.
This is the function used:
Integer(DateDiff(Date(2018,3,31),Date([Y_BIRTH_DATE],[M_BIRTH_DATE], [D_BIRTH_DATE])))/365
However, the computed column returns as (Empty).
If I run the expression without the Integer() and the /365 the function returns the appropriate number of days.
Use the function Days :
Days(DateDiff(Date(2018,3,31),Date([Y_BIRTH_DATE],[M_BIRTH_DATE], [D_BIRTH_DATE])))/365
Explanation : your result is a timespan, so it cannot be converted to integer. The Days function will extract the integer value of the timespan.
I saw that the previous answer solved your problem, but I'm including an alternative solution for others with similar questions.
You're currently calculating the age of a person in years by taking the number of days that the person has been alive up to some point in time (3/31/2018 in your example), and then dividing the number of days by 365, which will result in a Real number, such as 28.6 years.
By dividing by 365, your example doesn't take Leap Years into account. This may not be an issue for you, but it might be for another user.
The following expression will
Return the number of years as a real number (e.g. 28.6), as does
yours
Account for leap years in its calculation
DateDiff("year",
Date([Y_BIRTH_DATE],[M_BIRTH_DATE], [D_BIRTH_DATE]),
Date(2018,3,31))
Note that I've formatted the expression so every one of the DateDiff function's arguments has its own line. Obviously, the expression could be collapsed to a single line, I just did it to improve clarity.
Also, the example provided in Spotfire for the DateDiff function has the earliest of the two Dates being passed as the first Date argument, and the later Date being passed as the second Date argument. It's become my habit to do so, as well, so that's the order in which I've placed your Date arguments in my example.
I have to report basically the same information from inspections to two different clients, both of whom have provided me with an Excel spreadsheet in their own preferred format, and password protected. I have put the two sheets into my own workbook, and have managed to get 'almost' all the data on both sheets to populate from my own data. Where I am stuck though is on the time logs.
Client 'A' has each time and date in a single column, in the format "12.29.12 14:30". Client 'B' has two columns, date as "12/29/12" in the first, and time as "1430" in the second.
I'm trying to avoid having to type all the same dates and times twice - it can be several dozen lines - both to save effort and to avoid errors. What I really need to do is either concatenate the date and time from client 'B's report and put it into client 'A's, or split the date and time up in 'A's so I can put it ito 'B's. I've tried several approaches, but just end up with error codes or meaningless numbers.
Can anyone point me in the right direction?
Thanks,
Richard
Never mind... the very next thing I tried worked :-)
To anyone else reading this, the trick is not to concatentate the date and time values, but to add them together.
Richard
As you later pointed out in your own question, in order to manipulate date/times in Excel, you should add instead of concatenating.
The reason for this is that Excel stores all date/times as a number representing the number of days since January 1, 1900*. This number is stored as a 8-byte double.
Use Excel number formats to display the date/time format that you desire.
If you find in a worksheet that some cell's dates are in fact stored as text, use the DATEVALUE function.
*By default, Excel 2010 for Windows uses the number of days since 1900. There is an option to use the number of days since 1904 for compatibility with other versions.
I'm working on a project where I have to parse excel files for a client to extract data. An odd thing is popping up here: when I parse a date in the format of 5/9 (may 9th) in the excel sheet, I get 39577 in my program. I'm not sure if the year is encoded here (it is 2008 for these sheets).
Are these dates the number of days since some sort of epoch?
Does anyone know how to convert these numbers to something meaningful? I'm not looking for a solution that would convert these properly at time of parsing from the excel file (we already have thousands of extracted files that required a human to select relevant information - re-doing the extraction is not an option).
Excel stores dates as the number of days since 0-JAN-1900 (so 1-JAN-1900 would have a value of "1"). You can find a really good breakdown of how Excel handles dates and times here:
Dates And Times In Excel
When dates appear on screen in Excel as "5/9", "May 9th", or some such, it is a trick of the formatting and is not representative of the underlying data value. It sounds like your parsing program is pulling the underlying value, not the formatted date. In order to suggest a fix, though, I need to know what your parsing program is (Excel macro, formula, outside code, etc.).
DateTime.FromOADate (if you're using .NET) is the method you want. Excel dates are stored as doubles. If you have dates in the first two months of 1900 you might get bit by the Excel 1900 leap year bug.
From http://msdn.microsoft.com/en-us/library/system.datetime.fromoadate.aspx:
Double-precision floating-point number
that represents a date as the number
of days before or after the base date,
midnight, 30 December 1899. The sign
and integral part of d encode the date
as a positive or negative day
displacement from 30 December 1899,
and the absolute value of the
fractional part of d encodes the time
of day as a fraction of a day
displacement from midnight. d must be
a value between negative 657435.0
through positive 2958466.0.
All you need to do is format the cells correctly. Or am I misunderstanding your question -- are you saying you want to do it OUTSIDE of Excel? I wasn't sure. I'll delete this answer if it turns out to be stupid.
I finally thought I had found a way to acutally use excel productively but the code that I followed does not appear to work.
I'm thinking that the code is very limited and can't do what I want but I thought I'd ask to confirm - maybe it is my function that is the problem.
I want to calculate the sum of a row of values for the previous month based on how many days we are into this month (i.e. It is the 20th of April so I want to sum the first 20 days of March to compare against.)
=SUM(G4:ADDRESS(ROW(),7+$BR$3,4))
I basically want to SUM(G4:AA4) and have used the address function to return the cell reference AA4 by taking G4 and adding 20 to the column count.
ADDRESS(ROW(),7+$BR$3,4)
This successfully returns AA7 as expected HOWEVER, when I try to use the returning value in the SUM() function it throws an error...
Am I not able to use this reference in my calculation?
Try the OFFSET function instead:
=SUM(OFFSET(G4,0,0,1,$BR$3))
More info here
You can use indirect Attention in German the names are a bit different:
=SUMME(INDIREKT("G4:" & ADRESSE(4;8+19;1;4)))