How to take number input and convert to time in excel - excel

I am making an airplane reservation system on java. i got a sample database from online. only problem i have is the way the time is inputted.
and some times are 917 , or 22 , or 2. there is no 0 so i cannot just try and put a semicolon after 2 spaces.
Any one know if their is a way to do this, or some work around.

You can try:
=--TEXT(A1,"00\:00")
and format the result as "Time"
Edit:
I note you have changed your specifications to include that the times may be entered as the hour only: eg: 2 or 22. Try the revised formula below to handle that:
=--TEXT(IF(A1<=24,A1&"00",A1),"00\:00")

You can use the following formula:
=TIME(LEFT(A2,LEN(A2)-2),RIGHT(A2,2),)
A2 = the arrival time cell that you want to convert.
Also, make sure to change your output column to whatever time format you're looking for. Screenshot of results in action included.

Related

Problem to get the difference of two timestamps in seconds in MS EXCEL

The Problem:
I got two timestamps in Excel (German version) in this format:
2023-01-28-10.14.20.123456
2023-01-29-11.15.21.123456
and I need the difference of these two timestamps in seconds - which would be 90061.
What I tried:
To define a custom format for the timestamp:JJJJ-MM-TT-hh.mm.ss
To define a custom format for the timestamp:JJJJ-MM-TT-hh.mm.ss.000000 but I cannot define the .000000 for the nanoseconds because I get an Excel error that this format cannot be used
To use following formula =TEXT(D6-C6;"[mm]")
I tried to use the formula in this post which translates to =DATWERT(LINKS(C6;10))+ZEITWERT(TEIL(C6;12;8))-DATWERT(LINKS(D6;10))+ZEITWERT(TEIL(D6;12;8))
Nothing worked so far - any hints are appreciated - Thanks in advance
Or, a slightly shorter formula
i.e.
=86400*(VALUE(REPLACE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3,"-","/"),".",":",1),".",":",1),11,1," "))-VALUE(REPLACE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"-","/"),".",":",1),".",":",1),11,1," ")))
or, auf Deutsch
=86400*(WERT(ERSETZEN(WECHSELN(WECHSELN(WECHSELN(A3,"-","/"),".",":",1),".",":",1),11,1," "))-WERT(ERSETZEN(WECHSELN(WECHSELN(WECHSELN(A2,"-","/"),".",":",1),".",":",1),11,1," ")))
(changing the UI language doesn't update the , with ; though)
So, brutally long, but works based on what you gave.
I assume that that format and the number of characters will not change.
((LEFT(A3,10)-LEFT(A2,10))*86400)+(HOUR(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2)))*3600)+(MINUTE(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2)))*60)+(SECOND(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2))))+((MID(A3,21,6)-MID(A2,21,6))*1000)
One way to reduce it is to put the time calculation used in hour, minute and second into a separate cell.

Excel Time Formatting

So, I have an app, which automatically creates Excel tables. One of the column in those tables is something like a duration for a task. The format of the data looks like this: "1h12min" or "5min".
Now I want to be able to sum up all those numbers and have a total duration of all tasks.
I have tried using custom cell formatting, but I wasn't able to solve the problem that way, mostly because all time formats require a certain input method (like 00:00) and using '#' for the minutes resulted in them stacking up to 100 instead of 60.
I was gonna try an approach where I create one or more extra columns that convert those numbers into time format with the help of stuff like IF and CONTAINS functions, but my attempts are not working out.
Does anyone know of a good way to solve this problem?? Thanks in advance!
So this was my example:
So, cell DK8 contained "9 mins 18 secs".
The result "9.30"
And the function:
IFERROR(IF(ISERR(FIND("sec",DK8,1)),LEFT(DK8,FIND(" ",DK8,1)-1),LEFT(DK8,FIND(" ",DK8,1)-1)+(MID(DK8,FIND(" ",DK8,FIND(" ",DK8,1)+1)+1,FIND(" ",DK8,FIND(" ",DK8,4)+1)-FIND(" ",DK8,FIND(" ",DK8,1)+1)))/60),"")
You will need to edit to suit for hours etc

Excel IFS formula - range of number

I have a value in cell AB8 and I want to conditionally return a status depending on which value it takes between 1 and 30.
I want to save time and rather than type the scores 1-9 indivdually to turn into "EMERGING" (etc) is there a way I can put a range in?
IFS(AB8=1,"EMERGING",AB8=2,"EMERGING",AB8=3,"EMERGING",AB8=4,"EMERGING",AB8=5,"EMERGING",AB8=6,"EMERGING",AB8=7,"EMERGING",AB8=8,"EMERGING",AB8=9,"DEVELOPING",AB8=10,"DEVELOPING",AB8=11,"DEVELOPING",AB8=12,"DEVELOPING",AB8=13,"DEVELOPING",AB8=14,"DEVELOPING",AB8=15,"DEVELOPING",AB8=16,"DEVELOPING",AB8=17,"SECURING",AB8=18,"SECURING",AB8=19,"SECURING",AB8=20,"SECURING",AB8=21,"SECURING",AB8=22,"SECURING",AB8=23,"SECURING",AB8=24,"SECURING",AB8=25,"READY",AB8=26,"READY",AB8=27,"READY",AB8=28,"READY",AB8=29,"READY",AB8=30,"READY")
Try this:
=INDEX({"EMERGING","DEVELOPING","SECURING","READY"},MATCH(AB8,{0,9,17,25},1))
Or create this table in, say, A1:B4:
0 Emerging
9 Developing
17 Securing
25 Ready
And then the formula is just:
=INDEX($B$1:$B$4,MATCH(AB8,$A$1:$A$4,1))
CallumDA's answer is more clean.
But this can be accomplished with nested IF formulas.
=IF(AB8>=1,IF(AB8<=8,"EMERGING",IF(AB8<=16,"DEVELOPING",IF(AB8<=24,"SECURING",IF(AB8<=30,"READY")))))
This one might also work,
=IF(AND(AB8>=1,AB8<=8),"EMERGING",IF(AND(AB8>=9,AB8<=16),"DEVELOPING",IF(AND(AB8>=17,AB8<=24),"SECURING",IF(AB8<=30,"READY","INVALID NUMBER"))))

Excel if formula possibility

I have an issue that I don't personally know how to format. I need to subtract numbers that are in seconds, formatted to be viewed as 58.43 or 59.99, but that are sometimes in minutes, formatted as 1:01.33 for example.
I would also need to be able to subtract the numbers from each other to be recognized as (+1.08) or (-0.78), with the parentheses.
I'm sure I can elaborate somewhere, so let me know if this doesn't make any sense. Thanks
It depends if 58.43 is formatted as a number or time. Date and time are stored in number of days, so the time 58.43 is actually stored as the number 0.00067627314814814800000 (58.43/24/60/60).
If both values are time values, then the custom number format of the result can be:
(+s.00);(-s.00);(0.00);#
To handle both cases, instead of =A1-A2 you can try this something like this:
=IF(A1<1,A1,A1/86400)-IF(A2<1,A2,A2/86400)
If those are just time values formatted as mm.ss then you can use TIMEDIFF()
https://support.office.com/en-us/article/Calculate-the-difference-between-two-times-e1c78778-749b-49a3-b13e-737715505ff6
If not, try to convert them to time values and than use TIMEDIFF()
The first part is straightforward
Apply a default format of
ss:00
Then in conditional formatting use a formula
=A2>=TIME(0,1,0)
and apply a format of
m:ss.00
for the ones that are a minute or more.
There is no direct solution to the problem of displaying negative times short of changing the default date system used by Excel as you can see in a number of references. The only way to do it here is to test whether the result is positive or negative and display the positive difference with or without a minus sign.
=IF(B2>=A2,TEXT(B2-A2,"(+s.00)"),TEXT(A2-B2,"(-s.00)"))
The downside of this is that they are actually text values and you can't use them in any further calculations. However the results of A2-B2 are still good even if you can't display them directly, so you can use A2-B2 in subsequent formulae if you want to even if it is negative.

Excel Formula overly complex

I have a formula that builds a string with If statements, CONCATENATE, and text formulas.
My problem is that the formula's getting extremely larger than I ever wanted it.
My formula first looks to see if a cell if blank
=IF(I3="","",Else)
The Second part is to check if the letters "DKB" is in the H cell
=IF(ISNUMBER(SEARCH("*DKB*",$H3)),True,False)
The Third is if the duration (Cell F) has 0 hrs do not include (HH)
=IF(TEXT(F3,"HH")<>"00",CONCATENATE(TEXT(F3,"hh\h\r mm\m\i\n"),CONCATENATE(TEXT(F3,"mm\m\i\n"))
The Fourth one is if the are 0 min don't include min selection
=IF(TEXT(F3,"MM")<>"00",CONCATENATE(Text(F3,"HH:MM")),CONCATENATE(Text(F3,"HH"))
If I were to write all the ways this could get played out I would have a total of 10 IF's. I want a simple way to write for each option without having to write out each answer. I have a partial code but doesn't include the minute portion. Is there a better way to do this? as you can see me using only if statements I'm not an expert.
Here's a picture to demonstrate my sample data and sample output
If we could have a variable for the first part ie:10-17 to 9:10 PM
2nd variable for duration
3rd variable for DKB
Would this be possible
Perhaps something like this is what you're looking for:
=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")& "- "&TEXT(G3,"hh:mm AM/PM")&" "&TEXT(F3,"hh\h\r mm\m\i\n")&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))
=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")&"- "&TEXT(G3,"hh:mm AM/PM")&" "&IF(COUNTIF(F3,"*:00:*"),TEXT(F3,"hh\h\r"),IF(COUNTIF(F3,"00:*:*"),TEXT(F3,"mm\m\i\n"),TEXT(F3,"hh\h\r mm\m\i\n"))&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))))
This Will Make is so It won't show 00hr or 00min

Resources