| Index | Recent Threads | Unanswered Threads | Who's Active | Guidelines | Search |
| World Community Grid Forums
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 17
|
|
| Author |
|
|
jonnieb-uk
Ace Cruncher England Joined: Nov 30, 2011 Post Count: 6105 Status: Offline Project Badges:
|
I want to use some of the wealth of statistical data available on WGC to do some comparisons on runtimes etc (for my own interest).
----------------------------------------Can one of the long established crunching Guru's help get me started by answering an Excel spreadsheet related question? Runtime is reported in the format y:ddd:hh:mm:ss which is not a format recognised in Excel. So how do I handle the data? For example if I want to add 0:048:22:43:27 + 0:002:01:15:08 = 0:050:23:58:35 or subtract 0:050:23:58:35 - 0:002:01:15:08 = 0:048:22:43:27 what's the formulae? I've managed to work it by breaking the data down into its component parts, converting to everything to seconds and then reassembling the result in the original format but it's longwinded and inelegant. I'm sure there's a better way! ---------------------------------------- [Edit 1 times, last edit by jonnieb-uk at Jan 10, 2012 1:36:13 AM] |
||
|
|
Sgt.Joe
Ace Cruncher USA Joined: Jul 4, 2006 Post Count: 7850 Status: Offline Project Badges:
|
I had the same solution you did. It was a pain in the neck to set up, but got the job done.
----------------------------------------Cheers
Sgt. Joe
*Minnesota Crunchers* |
||
|
|
deltavee
Ace Cruncher Texas Hill Country Joined: Nov 17, 2004 Post Count: 4894 Status: Offline Project Badges:
|
In Excel sometimes longwinded is the only way. I do the same thing using the Excel "MID" function, but I am by no means an Excel expert. I don't know of a y:ddd:hh:mm:ss Excel date format.
|
||
|
|
wplachy
Senior Cruncher Joined: Sep 4, 2007 Post Count: 423 Status: Offline |
I've been playing around with this for about 4 years and haven't come up with an elegant way either. Because of the "60" carry the only way is to deal with each "segment" (years, days, hours, minutes, seconds) individually. I also break each down to seconds.
----------------------------------------For what it's worth following is the code I use to convert from "display: format (Y:DDD:HH:MM:SS) to seconds and back again. It also can deal with formats like 79h,22:41 (79 hours, 22 minutes and 41 seconds) Don't know if it "looks" any better than yours but it works just fine. To Use: A1 0:048:22:43:27 A2 0:002:01:15:08 A4 FmtTime(A1) 4229007 A5 FmtTime(A2) 177308 A6 FmtTime(SUM(A4:A5)) 0:050:23:58:35 Public Function FmtTime(vaRTVal As Variant, Optional stRTBase As String = "S", _
Bill P
![]() |
||
|
|
jonnieb-uk
Ace Cruncher England Joined: Nov 30, 2011 Post Count: 6105 Status: Offline Project Badges:
|
Thanks for all the comments.
----------------------------------------wplachy your code gives me something to explore and utilise. Part of the problem is that my knowledge of Excel is 15 years out of date due to a major career change. But "you're never too old to learn" so thanks. |
||
|
|
Former Member
Cruncher Joined: May 22, 2018 Post Count: 0 Status: Offline |
Of great help for all of us I think , so many thanks for above contributions
![]() |
||
|
|
Hypernova
Master Cruncher Audaces Fortuna Juvat ! Vaud - Switzerland Joined: Dec 16, 2008 Post Count: 1908 Status: Offline Project Badges:
|
There is also another issue if you play with stats for points or results.
----------------------------------------The numbers are with the comma separation for thousands instead of an apostrophy: Exemple WCG number: 123,765,456 Excel number should be: 123'765'456 It is impossible to do operations on the numbers with the WCG format. I use the following formula to do the conversion: =SUBSTITUE(H123;",";"'") H123 means that the number to be converted issued by a copie paste from WCG is in the cell H123. ![]() |
||
|
|
jonnieb-uk
Ace Cruncher England Joined: Nov 30, 2011 Post Count: 6105 Status: Offline Project Badges:
|
Two of the guys over at the MS Office Excel Forum have come up with formula for addition and subtraction of runtime data using the WGC format y:ddd:mm:hh:mm:ss.
----------------------------------------It took a few attempts to get completely right but I've run them against some test data and they appear to work correctly. (Testing involved breaking down input data into it's constituent parts, coverting to seconds, adding or subtracting, then converting the result back to the WGC format. This was then compared with results obtained using the formula below and the results were identical.) Data ( y:ddd:mm:hh:mm:ss) in Cell A5 and Cell B5; Formula in Cell C5: Addition formula: (courtesy of Richard Buttrey ) =TEXT(LEFT(B5,FIND(":",B5)-1)+LEFT(A5,FIND(":",A5)-1)+IF(MID(A5,3,3)+MID(B5,3,3)>=365,1,0),"0")&":"&TEXT(MOD(MID(B5,3,3)+MID(A5,3,3),365)+IF(RIGHT(A5,8)+RIGHT(B5,8)>1,1,0),"000")&TEXT(MOD(RIGHT(B5,8)+RIGHT(A5,8),1),":hh:mm:ss") Subtraction formula: (courtesy of Daddylonglegs) =LEFT(B5,FIND(":",B5)-1)-LEFT(A5,FIND(":",A5)-1)-(RIGHT(A5,12)>RIGHT(B5,12))&":"&TEXT(MOD(MID(B5,FIND(":",B5)+1,3)-MID(A5,FIND(":",A5)+1,3)-(RIGHT(A5,8)>RIGHT(B5,8)),365),"000")&TEXT(MOD(RIGHT(B5,8)-RIGHT(A5,8),1),":hh:mm:ss") Notes: 1. Copy/Paste the formula from here to an Excel spreadsheet should work ok. 2. Since I haven't, at this point in time, the knowledge to totally understand/verify the formulae, you should inspect the results produced to ensure correctness. 3. Because cells are text format, subtracting a higher value from a lower value will report a negative as in this example: 0:003:01:11:47 - 0:009:05:44:33 = -1:358:19:27:14 4. If the input data is obtained from an external data connection remember that it may have leading or trailing spaces, which may cause unexpected behaviour in the computation. I handle this by using the "=TRIM() " function on the raw data. Alternatively modify the addition and subtraction formulae to enclose each individual cell reference with TRIM() 5. The formulae assume year=365 days (i.e. No Leap Year) 6. To sort a table of Runtime data produced in this way its necessary to sort on Values, Order Z - A, to produce a table in descending order of magnitude (Because the data is formatted Text rather than Numeric.) 7. Following on from (6) there's a problem: The ddd:mm:hh:mm:ss part of the WGC format is fixed length but "y:" is floating. The sort operation in (6) only works where "y:" =< 9. To handle values of "y:" > 9 it is necessary to introduce leading 0's such that all the "y:" data in the table is of uniform length. I hope the above proves useful to other people. I'm on a very steep learning curve to update my Excel knowledge so comments, criticism, amendments are most welcome. ---------------------------------------- [Edit 1 times, last edit by jonnieb-uk at Jan 10, 2012 10:32:35 PM] |
||
|
|
anhhai
Veteran Cruncher Joined: Mar 22, 2005 Post Count: 839 Status: Offline Project Badges:
|
jonnieb-uk,
----------------------------------------The formula is over my head. I personally just use basic functions to do what is necessary. Believe it or not, there is a fairly simple solution available. My method allows for addition, substraction, sorting, and whatever else that comes to mind. Here is a simple question for everyone. Why do you need to use "0:048:22:43:27"? Why can't it be Yrs=0, Days=48, Hrs=22,Min=43, and Sec=27? The first method is very hard for excel to understand. But the second, is very easy for excel to understand. When you have a bunch of data in the y:ddd:mm:hh:mm:ss format, just copy it to notepad. Ideally, you would want 1 piece of data per line. Then open up the notepad file using excel. Excel will ask you some questions about how to format the file, one of the question is what are the delimeters, just make sure you choose ':' as a delimeter. The result will be easy to read and easy to modify as you see fit afterwards. All of the "years" data will be under column A. All of the "days" data will be under column B. All of the "hrs" data will be under column C. All of the "minutes" data will be under column D. All of the "seconds" data will be under column E. Excel can actually handle this type of information. You can easily sort this information, however, if you want to add, subtract, and stuff with it, you will need a column F. Column F is basically column A-E in seconds. Most ppl probably already know how to create column F, but I will just type it out anyways. In the F1 cell type "=A1*31536000+B1*86400+C1*3600+D1*60+E1" then you can highlight the rest of the F column, and use fill down. So now, you can do addition, subtraction or whatever you want since it all everything is in seconds. You will also want to reconvert things back into the y:ddd:mm:hh:mm:ss format using column K-N. The principles of this idea should be fairly easy to understand with just the basic understand of how excel works. Modify the idea as you see fit ![]() |
||
|
|
jonnieb-uk
Ace Cruncher England Joined: Nov 30, 2011 Post Count: 6105 Status: Offline Project Badges:
|
anhhai
----------------------------------------Thanks for the reply. I agree with your final paragraph The principles of this idea should be fairly easy to understand with just the basic understand of how excel works. Modify the idea as you see fit Had your method been available to me when I first started browsing the Forum I would probably have adopted it in toto. I waded through the FAQs but there was nothing relevant to someone like me who just wants to manipulate WGC data to satisfy a curiosity. Being a newbie I was initially nervous about posting to a Forum predominately occupied by people who've been crunching for years. As previously noted my Excel knowledge was somewhat dated but its been a worthwhile and enjoyable process learning some new Excel Functions and putting them into practice (even if it is a little like reinventing the wheel). When it comes down to it, its a matter of personal preference how to handle the data. But if the discussion in this thread helps others in their quest to manipulate WGC data then we've both achieved something positive. |
||
|
|
|