yearfrac | Difference between dates as a fraction of 1 year | Date Time Utils library
kandi X-RAY | yearfrac Summary
kandi X-RAY | yearfrac Summary
Difference between dates as a fraction of 1 year
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Calculates the effective difference between two dates .
- Calculate the effective frequency of two dates .
- Difference between two dates .
- Calculate difference between two dates .
- Convert Julian day to date .
- Compute the yearfrac vectors between two vectors .
- Calculate the year fraction between two dates .
- Get the version string .
- Convert a date to Julian day .
- Return whether the year is a validaleap year .
yearfrac Key Features
yearfrac Examples and Code Snippets
Community Discussions
Trending Discussions on yearfrac
QUESTION
oversimplified i have two columns: Date and Text; I want to check my current amount of vacation days based on the first date in row 2, so i came up with the following formula:
="Available vacation days: "&YEARFRAC(A2;TODAY())*12*(25/12)
I calculate the fraction of the year based on the first date and todays date, multiply it by 12 to get months and multiply it again by the total amount of vacation days in my contract per month. Now i got another formula to collect me all cells in column B containing "Vacation", pretty straight forward:
=COUNTIF(B:B;"Vacation")
Now the interesting part - i got the formula who gives me a boolean if a datetime matches the 24th or 31st of december:
=AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12)
I want to count vacation days happening on a 24th or 31st of december as a half-vacation day (0.5), and otherwise fully (as a 1). Then i want to combine my first statement with this result and subtract the used vacation days. I read about VLOOKUP and XLOOKUP but am unsure if this fits this purpose. I want to avoid having an extra column with my boolean returns and rather have this one cell giving me all the information combined.
...ANSWER
Answered 2021-Dec-23 at 20:32Without introducing another column, and using DAY
and MONTH
It's nearly impossible, and just unnecessarily so...
Please reconsider this, what will happen if you want to add 4th of July as a holiday?
Your formula =AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12)
only works for 1 row at a time. So, we can't ever use it with a list, because you will get the whole list as a result every single time. You can't divide them into smaller lists and join them together, there is no such functionality without VBA.
In the future, do not set arbitrary constraints like "no additional columns", you can hide them if you don't like them. And if you don't need them, remove unnecessary rows like non-vacation rows. They are irrelevant, so why not separate the two.
Just to prove my point, here's the solution you wanted:
SolutionQUESTION
I've got a sheet with Data. I want to calculate the difference between date now and the date which are in cells C3:C10. And the results are stored in cells D3:D10.
That part I got it so far.
But if someone manipulates the values in the result cells then the VBA should recalculate those cells and correct the results.
...ANSWER
Answered 2021-May-28 at 19:11The first thing to do is check if the change has been made in C3:C10
, you can use Intersect
for that.
Then you should disable events to stop the code triggering itself, use Application.EnableEvents = False
for that.
Next loop through Target
in case more than one cell has been changed and perform the required actions/calculations.
Finally re-enable events using Application.EnableEvents = True
QUESTION
I want to implement one logic of Excel sheet in oracle database.
I m using YEARFRAC()
in Oracle in a stored procedure but I am getting error as
Error(166,22): PLS-00201: identifier 'YEARFRAC' must be declared
Here is my code
...ANSWER
Answered 2021-May-07 at 23:37YEARFRAC
is an Excel function (and other supporting spreadsheets).
As your error states:
QUESTION
I'm relatively new to Python but I have a complicated issue which I think requires a few different functions, but I don't know where to start.
It's kind of straightforward to do in Excel, by using the PRODUCT function, based on a starting point up to the most recent renewal date (in this example it would be 01/10/2020) and simply multiplying this Product function totals of each of the starting point elements, to give the current renewal date total, broken down by element values.
I want to write this in Python but besides the very basic info on Python 3.8 math.prod(), there doesn't seem to be anything more that I can find online to resolve/assist me with this.
I have the following 3 Pandas dataframes (I copied the data from Excel and pasted in the links below for ease of the explanation, but I've imported these as dataframes in my test code).
The data comes in this form which need to be collated together and a revaluation, broken down by the different elements of a member's entitlement, needs to go from the starting date ("StartDate") to the current “renewal” date (01/10/2020) - if possible, there also needs to be a pro-rata done in complete months between the StartDate to the 1st renewal date (equivalent to the Excel YEARFRAC function).
The 3 dataframes are:
- Identifiers of members with certain basic information. The most important piece of data is the ‘StartDate’ column, as it's the point to revalue member benefits from. It needs to have a function that calculates, I'm guessing here, the TimeDelta (in months) from the StartDate to the member's 1st renewal date, which needs to be a pro-rata of the difference e.g. 1st member started on 01/02/2016 so the 1st renewal needs to have a pro-rata of 8 months. I'd also like to set a boolean where if True, the pro-rata occurs otherwise it doesn't
List of MemberIDs and StartDates
- Increase factors. The elements will either increase or stay level (never decrease in value)
Increase rates by year (index used is the Renewal Date)
- Member assets - linked to (1) by the member identifier (MemberID). These different elements should escalate by the increase factors in (2) and these figures are the elements as at the StartDate.
Essentially, the function(s) need to calculate when the first renewal date is after the StartDate, apply a pro-rata increase if the boolean is True, then work out the range of renewal dates and increase factors between the StartDate and the latest renewal date and finally apply the Product for this date range on the StartDate elements.
With this being my first ever post, my apologies if it's not quite in the format you might expect or with any Python code as I'm very new to Python and to StackOverflow (they wouldn't even allow me to post the tables directly, only as links to images). The data I've provided, due to data protection, are dummy dates but relatively based on the actual data.
Any questions you have, I'm happy to provide more information. Thanks for any help in advance!
EDIT: Please see this temporary solution that I'm using, but it's without the pro-rata of the 1st increase between StartDate to the 1st increase date: Solution (without pro-rata)
- The MemberID in the example, the Python function should find the 1st increase after StartDate as 01/10/2016 (DD/MM/YYYY)
- The function should then check the Renewal Date increases by each element between 01/10/2016 and the latest Renewal Date at 01/10/2020. The Excel PRODUCT formula gives the element increases as: 1.38823, 1.20396 and 1.20462 for elements 1 to 3 respectively
- Finally, the elements from the StartDate are multiplied by the PRODUCT totals of each tranche, to give the current value
ANSWER
Answered 2020-Nov-14 at 21:43I've whipped something up here that should give you a primer. The first code block just recreates your data. The second block iterates over each member, gets the appropriate renewal dates, and then just multiplies the fetched rows across the DataFrames.
It's not as efficient as it could be due to using the explicit for-loop over member ids instead of broadcasting, but it should get you started.
QUESTION
If one uses Excel's YEARFRAC(date1,date2,1)
function then Excel will use the basis as per the second parameter. This does not matter if date1 and date2 are in the same year, but it does matter if date1 is a leap year (e.g. 2020) and date2 is a non-leap year (e.g. 2021)
I think that a more accurate calculation will take into account that the basis of date1
can be different to the basis of date2
.
For instance YEARFRAC(15/12/2020,15/01/2021,1)
returns 0.08493151
But the real calculation is (31/12/2020-15/12/2020)/366 + (15/01/2020-31/12/2020)/365 = 0.084811737
I implemented the following in VBA. Does anyone have any fundamentally better way of doing it (either in Excel or in VBA)? (I am not looking for minor improvements to my rushed VBA code)
Call it using yearFracVBA("AA1","AA2")
ANSWER
Answered 2020-Oct-21 at 15:46The following code does not require Excel. It will work in any VBA Application:
QUESTION
I have a input box (using C# razor) that user can input a string. I have use ToString("#,#0.00") to format as a numerical value since user will input a numerical value in the input box. When the user press enter it will calculates automatically for example 'average' and generate a percentage which it works. And it will updates the cell. The problem is that I want the input box to accept comma separated (e.g 2,000 or 30,000)in the input box. However, when I did some testing by trying to input numerical value with comma separator, 2,000 will become 2.00. Im trying to figuring out but I couldn't and i am stuck. Can you please help me. Thanks.
This is my html razor code ( I have post the partial code of it since too long):
...ANSWER
Answered 2020-Aug-21 at 06:17Ok I got it fixed. By using replace(/[^\d.]/g, "") which can format the numerical.
I modified this line of code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install yearfrac
(If your git repo is stored in a folder with whitespaces, then don't use the subfolder .venv. Use an absolute path without whitespaces.).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page