I have a spreadsheet calculating SLA s between two dates and displays in the format X Days X Hours X Minutes.
=IF('My Access Month Data'!I3="","",INT(D3-C3)&" Days "&HOUR(MOD(D3-C3,1))&" Hour "&MINUTE(MOD(D3-C3,1))&" Minutes")
I am looking to run a calculation on the results if the above formula that will basically give me a Y if the results are less than or equal to 1 day 0 hours and 0 minuets and a N if the time has exceeded this.
Related
I cannot figure out the approach to this as the principle amount shall change after every year(if calculated annually, which shall be the easiest). Eventual goal is to calculate exact number of years, months and days to earn say 150000 as interest on a deposit of 1000000 at an interest rate of say 6.5%. I have tried but cannot seem to figure out how to increment the year/month/day in the loop. I don't mind if this is down voted because I have not posted any code(Well, they are wrong). This is not as simple as it might seem to beginners here.
It is a pure maths question. Compound interest is calculated as follows:
Ptotal = Pinitial*(1+rate/100)time
where Ptotal is the new total. rate is usually given in percentages so divide by 100; time is in years. You are interested in the difference, though, so use
interest = Pinitial*(1+rate/100)time – Pinitial
instead, which is in Python:
def compound_interest(P,rate,time):
interest = P*(1+rate/100)**time - P
return interest
A basic inversion of this to yield time, given P, r, and target instead, is
time = log((target+Pinitial)/Pinitial)/log(1+rate/100)
and this will immediately return the number of years. Converting the fraction to days is simple – an average year has 365.25 days – but for months you'll have to approximate.
At the bottom, the result is fed back into the standard compound interest formula to show it indeed returns the expected yield.
import math
def reverse_compound_interest(P,rate,target):
time = math.log((target+P)/P)/math.log(1+rate/100)
return time
timespan = reverse_compound_interest(2500000, 6.5, 400000)
print ('time in years',timespan)
years = math.floor(timespan)
months = math.floor(12*(timespan - years))
days = math.floor(365.25*(timespan - years - months/12))
print (years,'y',months,'m',days,'d')
print (compound_interest(2500000, 6.5, timespan))
will output
time in years 2.356815854829652
2 y 4 m 8 d
400000.0
Can we do better? Yes. datetime allows arbitrary numbers added to the current date, so assuming you start earning today (now), you can immediately get your date of $$$:
from datetime import datetime,timedelta
# ... original script here ...
timespan *= 31556926 # the number of seconds in a year
print ('time in seconds',timespan)
print (datetime.now() + timedelta(seconds=timespan))
which shows for me (your target date will differ):
time in years 2.356815854829652
time in seconds 74373863.52648607
2022-08-08 17:02:54.819492
You could do something like
def how_long_till_i_am_rich(investment, profit_goal, interest_rate):
profit = 0
days = 0
daily_interest = interest_rate / 100 / 365
while profit < profit_goal:
days += 1
profit += (investment + profit) * daily_interest
years = days // 365
months = days % 365 // 30
days = days - (months * 30) - (years * 365)
return years, months, days
years, months, days = how_long_till_i_am_rich(2500000, 400000, 8)
print(f"It would take {years} years, {months} months, and {days} days")
OUTPUT
It would take 1 years, 10 months, and 13 days
I am trying to do a time subtraction in excel of 30 minutes and I am running into a speed bump. So the table I have are as follows.
Table "Schedule"
Column 1 is day of the week (Mon-Sun) (formated as general, as this is plain text)
Column 2 is start time of the shift (formated as h:mm AM/PM)
Column 3 is end time of the shift (formated as h:mm AM/PM)
Column 4 is duration of the shift (start to end) (formated by formula (TEXT(col3-col2,"h:mm")) )
Column 5 is paid hours (if the total hours is over 6.5 then subtract 0.5 hours for an unpaid lunch) (formula IF(col5>"6:30",col5-"0:30",D5) )
The issue is any time allotment over 10 hours start to end (where column 4, the duration hits 10 hours) no lunch is subtracted at all.
So...
Start 9:00 AM, End 6:59 PM, Hours Total 9:59, Hours Paid 9:29
But...
Start 9:00 AM, End 7:00 PM, Hours Total 10:00, Hours Paid 10:00
and that should obviously not happen. I can't find anything on google so I figured the excel gurus here may have some advice.
Thanks!
If your time columns are stores using excel's dedicated time format, this should be straightforward. Mixed data types are likely your problem.
First, be sure your time columns (columns 2 and 3) are set using the time function, i.e.,
=time(hours,minutes,seconds)
Then, you should be able to add and subtract easily.
Column 4: = column 3 - column 2
... then subtract 30 minutes also using the time() function:
Column 5: = if(column 4 > time(6,30,0),column 4 -time(0,30,0),column 4)
Excel stores time values from 0 to 1. So 24 hours=1, 12 hours=.5 etc. That means 6.5 hours=0.270833333 and .5 hours=0.020833333. As a result you can just do a simple if statement.
=IF(D2>0.270833333,D2-0.020833333,D2)
To turn it into a time format, is to just use excel's time formating options.
Scenario:
I have an excel Timesheet which needs to calculate Standard Time 1x, Overtime 1.5x, Overtime 2x based on the following values:
If the start time and finish time fall between 08:00 and 16:45, then sum the hours x1
If the finish time falls between 16:45 and 00:00, then sum the hours by x1.5
If the finish time falls between 00:00 and 08:00 then sum hours by x2
Example Data:
Start time Finish time Standard time Overtime x1.5 Overtime x2
08:30:00 17:00:00 7.5 0.5 0
17:00:00 01:00:00 0 7 1
01:00:00 10:00:00 2 0 7
06:00:00 12:00:00 4 0 2
I have been racking my brain and possible ways to do this but keep falling short, does anybody know how I would go about creating a formula to do this kind of some?
Ah, I am too late as the other answer has been accepted which is great if it covers a 48-hour period. Anyway this is how mine looks - can provide some explanation later.
Here are the definitions relative to cell D2
So the basic formula is
=MAX(0,MIN(ClockOff+Split,ShiftEnd)-MAX(ClockOn,ShiftStart))
This is based on the standard formula for calculating the overlap of two ranges quoted in various places e.g. here but adds 1 (equal to one whole day) for the case when the end of shift is after midnight. This works for standard time (starting in D2) and overtime X 1.5 (starting in E2) as long as the end of the evening shift (in J4) is also entered as 1 whole day (24:00 hours). For overtime X 2, both the start of shift (0:00) and end of shift (08:00) have to be adjusted by 24 hours if the hours worked are split across midnight so the formula in F2 is
=MAX(0,MIN(ClockOff+Split,ShiftEnd+Split)-MAX(ClockOn,ShiftStart+Split))
Create a matrix of times and use an if statement to determine if the time falls within the shift or not. Sum the times as required for each shift.
Here's a link to my example http://www.scotlang.com/Overtime.xlsx.
Can some one help me with a simple forumla in excel for the following problem.
I need to be able to predict an average price for the month. For example, if the current price is $1000 and there are 5 days left until the end of the month, I believe the price will increase £50 p/day. 1050 then 1100 1150 etc So the average price for the last six days will be 1100?
i would like to be able to do a forumla that works it out from the current price, the increase amount and the days left with out having to have a cell for each day etc?
Is this possible? i have tried google but have come up with nothing, a difficult question to articulate.
Sounds like you're having troubles finding the days in the month and the percentage of the month that has already passed / left
To calculate the number of days in the current month use this formula
=EOMONTH(NOW(), 0)-EOMONTH(NOW(), -1)
To calculate the current day of the month use this formula
=DAY(NOW())
To calculate the percentage of the month already gone
=DAY(NOW()) / (EOMONTH(NOW(), 0)-EOMONTH(NOW(), -1))
To calculate the percentage of the month remaining
=1 - (DAY(NOW()) / (EOMONTH(NOW(), 0)-EOMONTH(NOW(), -1)))
I'm not clear what you are averaging - is it 5 days or 6?
If you start with 1000 and average 5 days then you are averaging 1000, 1050, 1100, 1150 and 1200 so the average is 1100 - if that's the required result try this formula
=A2+B2*(C2-1)/2
where A2 is price, B2 increase amount and C2 days left
If you are averaging 6 days then that starts at 1000 and ends at 1250 so average is 1125 and the formula should be:
=A2+B2*C2/2
I am trying to put together an excel spreadsheet to track working time. A standard working day is say 8 hours with one hour lunch, say 40 hours total, 35 hours working. I need to track over and under time on a given day, and total this for a week period. The reason is to that if someone only takes a 30 minute lunch for three days, they can then take 1.5 hours off early at the end of the week for example.
Example daily record:
Mon - 9-6, 1 hour lunch = 8 working hours, 1 hour lunch, balance = 0 (the perfect day)
Tue - 8-6, 1 hour lunch = 9 working hours, 1 hour lunch, balance = +60 (one hour over)
Wed - 9-4, 1 hour lunch = 7 working hours, 1 hour lunch, balance = -60 (one hour under)
Thu - 9-6, 30 min lunch = 8 working hours, 30 min lunch, balance = +30 (30 mins over)
Fri - 9-6, 30 min lunch = 8 working hours, 30 min lunch, balance = +30 (30 mins over)
Example end of week totals
I am recording start/end/lunch times in excel in custom "time format" cells: 09:00 - 17:00
I am getting the hours with this formula: =TEXT(End-Start,"hh:mm")
I enter the lunch time in "time format" 00:30 (30 mins)
I get the actual time worked with this formula: =TEXT(Total-Lunch,"hh:mm")
When I try to add together / sum the values however I am not getting anything...
Any thoughts?
I do this with six columns
Date / Start / Lunch / Lunch / Stop / total
3-sep / 8:29 AM / 12:30 PM / 1:30 PM / 5:44 PM / 8.25
For total, I calculate with the function =MROUND((D5-C5+F5-E5)*24,0.25). This rounds the total to the closest 0.25 hour (that is, 15 min).
Just for kicks, I accumulate the excess hours. Excel will put in the current time by pressing Ctrl+Shift ; (semicolon).