Excel function to cut data between to fixed character strings - excel

I have the following text in an excel cell:
SampleID: S-2016-011451 SubmitterID: EIROSSME Sample Name: T1 BTMs - 6/26/16 10:00 PM Lot Nbr: ProductID:
I need to cut the data so that it reads as:
T1 BTMs 6/26/16 22:00
I can format the date using text($cell,"mm/dd/yy hh:mm") but I can't get the =mid(...) to truncate the data between "Name:" and " - ".

1st: =mid(B2;63;26)
2nd: =mid(B5;1;8)
3rd: =mid(B5;11;18)
4th: =concatenate(B7;B8)
If you want to cut between Name: and -, just use:
=find("Name: ";B2)
=find(" -";B2)
and then:
=mid(B2, find("Name: ";B2)+5;find(" -";B2)-find("Name: ";B2)-5)
I.e.:

Assuming you know what to expect after Sample Name:
=MID(A1,SEARCH("Sample Name:",A1)+13,7)
=MID(A1,SEARCH(A4,A1)+LEN(A4)+3,17)
And now you just have to convert the second cell to the date format you want (which you already know how) and concat them like A4&C4 (if C4 is the date after conversion).
Hope it helps ;)

Use SUBSTITUTE to change, so use SUBSTITUTE(a1,"Sample Name:","£££") and SUBSTITUTE(a1,"PM Lot Nbr:","$$$") together, then you'll get £££ T1 BTM......$$$ then you can find the instances of the £££ and $$$ and mid inbetween then, or RIGHT, then LEFT
This gives you the points to cut from and to. You can use the find of the values that we are also substituting, so find PM Lot Nbr etc.
SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","###"),"PM Lot Nbr","|||")
Something similar to this (not complete, I shall finish and tidy)
=MID(SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","###"),"PM Lot Nbr","|||"),LEN("###") + FIND("###",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","###"),"PM Lot Nbr","|||")),(FIND("|||",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","###"),"PM Lot Nbr","|||"))-FIND("###",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","###"),"PM Lot Nbr","|||"))-LEN("|||")))

Related

Excel: Calculate average time (duration), with criteria, between 2 columns

Breaking my head over this, time to look for help :(
I have a sheet with raw data, as illustrated below.
I'd like to calculate the average duration per TestName (column A) between the 2 timestamps (B and C) in another sheet.
How can I do this in 1 formula?
Note 1: The correct answer is (done manually)
test1 = 26:41:23
test2 = 08:23:10
Note 2: 1 formula please, without adding extra columns to calculate the duration per each first
Note 3: I cannot change the format of the raw data
Note 4: ignore empty fields
Thank you!
Use a new Column D to calculate the difference between start and end date on each row:
=DATEVALUE(C2)+TIMEVALUE(C2) - (DATEVALUE(B2)+TIMEVALUE(B2))
Next calculate the average on test1 and test2
=AVERAGEIFS($D:$D, $A:$A, "test1")
=AVERAGEIFS($D:$D, $A:$A, "test2")
Note that I'm using a comma as separator, in some languages, other separators, like semicolon are needed to write the formulas properly.
Now format the view to display at least the days in addition to the time: "DD - hh:mm:ss". Going beyond 31 days is a bit difficult as the month will count up.
If you don't like the formatting, go with the raw number format and extract the information through a bit of math. If it shows for example 1,5 it means one and a half days. I hope you can handle converting decimals to hours, minutes and seconds. MOD(ulo) and Rounddown are going to be your friends. :-)

Excel Using concatenate to compare dates

I have a table containing several columns of which one is a date/time field. I am trying to get a count of instances per day using the following
=COUNTIFS(Table4[Data],"Apple",Table4[Date],(CONCATENATE(V4,"*")))
Data Date Comp Date Count
Apple 6/12/18 1:00 PM 6/12/18 12:00 AM 0
Apple 6/12/18 7:00 AM
Orange 6/12/18 1:30 PM
Apple 6/11/18 11:23 AM
From my understanding of all the moving parts here I should be checking to see if "Apple" exists in the data column and then if "6/12/18" with any amount or type of characters after it exists. If both are true I will then get a count + 1 leaving me with a value of 2 in the above example.
What I actually get however is a 0 unless I match the time portion of date the data to be exactly the same and then removed the wildcard ,"*" from the equation.
Am I doing something wrong or can the wildcard not be used to accomplish what I am trying?
Thanks!
I think you should set your criteria properly.
If you add an additional column next to your Date that contains calculates the integer value of your date using INT() and format the display as DATE (m/d/yyyy) you should then be able to use the following COUNTIFS formula
=COUNTIFS(Table4[Data], "Apple", Table4[Date], "=6/12/18")
See the explanatory video from their Office' support site: https://support.office.com/en-us/article/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842
If your [Date] column is a datetime or smalldatetime, you can work with it using CONVERT function, depending on how you want to group.
For example, if you don't care about the time to do the group, you could use the next query:
SELECT CONVERT(varchar,[Date],103), [Data], COUNT(*)
FROM [test_delete].[dbo].[Table1]
GROUP BY CONVERT(varchar,[Date],103), [Data]
This should result in something like this:
[Date] [Data] [Count]
11/06/2018 Apple 1
12/06/2018 Apple 2
12/06/2018 Orange 1
Hope this helps you
If your dates are stored as dates instead of text, use the following:
=COUNTIFS(Table4[Data],"Apple",Table4[Date],">="&V4,Table4[Date],"<"&V4+1)

oracle date to string

I have this problem: I want to convert the sysdate to string, using fillmode on month, day and hour only. However,
select to_char(sysdate, 'fmmm/fmdd/yyyy fmhh12:mi:ss am') from dual
gives me results like
11/13/2013 9:45:**0** am
although it should be
11/13/2013 9:45:**00** am
any thoughts? Thanks in advance
You shouldn't use the FM format model, because FM, as written in the documentation:
FM - Used in combination with other elements to direct the suppression of leading or trailing blanks
So using FM will make your final string shorter, if possible.
You should remove the FM from your format model mask and it will work as you expect:
select to_char(TRUNC(sysdate), 'mm/dd/yyyy hh12:mi:ss am') from dual;
Output:
11/13/2013 12:00:00 am.
I've changed my answer after reading Nicholas Krasnov's comment (thanks).
More about date format models in Oracle Documentation: Format models
Edit
Yes, the code I provided would return, for example, 01-01-2013. If you want to have the month and day without leading zeroes, than you should write it like this: fmDD-MM-YYYY fmHH:MI:SS.
The first fm makes the leading zeroes be truncated. The second fm turns off that feature and you do get leading zeroes for the time part of the date, example:
SELECT TO_CHAR(
TO_DATE('01-01-2013 10:00:00', 'DD-MM-YYYY HH12:MI:SS'),
'fmmm/dd/yyyy fmhh12:mi:ss am')
FROM dual;
Output:
1/1/2013 10:00:00 am.

How do I convert hh:mm:ss.000 to milliseconds in Excel?

I have a device which outputs the time in the format hh:mm:ss.000, e.g., 00:04:58.727 and I need to convert these to milliseconds.
I can't change the way the device outputs the times so I have to do it in Excel, but I don't know VB so am looking for a cell-by-cell solution.
Let's say that your time value is in cell A1 then in A2 you can put:
=A1*1000*60*60*24
or simply:
=A1*86400000
What I am doing is taking the decimal value of the time and multiply it by 1000 (milliseconds) and 60 (seconds) and 60 (minutes) and 24 (hours).
You will then need to format cell A2 as General for it to be in milliseconds format.
If your time is a text value then use:
=TIMEVALUE(A1)*86400000
UPDATE
Per #dandfra's comment this solution may not work in the Italian version of Excel.
Using some text manipulation we can separate each unit of time and then sum them together with their millisecond coefficients.
To show the formulas in the cells use CTRL + `
Use
=LEFT(B2, 2)*3600000 + MID(B2,4,2) * 60000 + MID(B2,7,2)*1000 + RIGHT(B2,3)
you can do it like this:
cell[B1]: 0:04:58.727
cell[B2]: =FIND(".";B1)
cell[B3]: =LEFT(B1;B2-7)
cell[B4]: =MID(B1;11-8;2)
cell[B5]: =RIGHT(B1;6)
cell[B6]: =B3*3600000+B4*60000+B5
maybe you have to multiply B5 also with 1000.
=FIND(".";B1) is only necessary because you might have inputs like '0:04:58.727' or '10:04:58.727' with different length.
Rather than doing string manipulation, you can use the HOUR, MINUTE, SECOND functions to break apart the time. You can then multiply by 60*60*1000, 60*1000, and 1000 respectively to get milliseconds.
Here it is as a single formula:
=(RIGHT(D2,3))+(MID(D2,7,2)*1000)+(MID(D2,4,2)*60000)+(LEFT(D2,2)*3600000)
try this:
=(RIGHT(E9;3))+(MID(E9;7;2)*1000)+(MID(E9;5;2)*3600000)+(LEFT(E9;2)*216000000)
Maybe you need to change semi-colon by coma...

Excel Custom Number Formatting for US Treasury Bond Quotes

I am having some trouble using the custom number format feature in Excel to display US Treasury futures quotes.
The format by which they are displayed in is:
121'167
Which is equivalent to 121 + 16.75/32
If the last digit is a 5, as in 121'165, then it is equivalent to
121 + 16.5/32
If the last digit is a 2, as in 121'162, then it is equivalent to
121 + 16.25/32
and finally if the last digit is a 0, as in 121'160, then it is equivalent to
121 + 16/32
Is there a way to implement this definition using the custom number formatting feature or is it beyond it's capability?
This is one insane format: add fractions, then use decimals in the dividend, and then truncate those decimals...
But enough of the ranting. This should do the job, if I understood your specification correctly:
=TRUNC(A1)&"'"&INT(MOD(A1,1)*320)
Number formats alone cannot do this, because they cannot do actual conversions of the numbers (apart from the built-ins like date/time).
you can apply the TEXT() function to both of your values and concatenate them into a single string.
example (A1 = 121, B1 = 16.75)
C1: =TEXT(A1,"###") & "'" & TEXT(B1*10-1,"###") & "/32"
You need to work out rounding (I put a constant *10-1 into the 2nd term) and how to obtain the "/32" ... I couldn't spot that from your question
Hope that helps
good luck
=TRUNC(A1)&"'"&ROUND((MOD(A1,1)*32),1)
Where A1 = 109.6406
This is what worked best for me. I simply had to take a 2-year note quote in the form of, as an example, 109'20.5 and replicate in excel. I converted the quote into 109.6406 (109 + 20.5/32) and applied the above formula.
I know this is a bit dated, but stumbled upon this today and needed the same information. Here is what I use, replace the cell across the formula to pull the quote.
5 yr:
=LEFT(J22,3)+(RIGHT(J22,3)/320)+IF(INT(RIGHT(J22,1))=2,0.0015625,IF(INT(RIGHT(J22,1))=7,0.0015625,0))
10 yr: =LEFT(B28,3)+(RIGHT(B28,3)/320)

Resources