Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Dates of Monk promotion (covered)

by chacham (Prior)
on Jun 17, 2015 at 14:48 UTC ( [id://1130824]=note: print w/replies, xml ) Need Help??


in reply to Re: Dates of Monk promotion (covered)
in thread Dates of Monk promotion

Nice!

Is the x-y from x to y? The format seems to be: 1-2, 2-3, 3-4. 0-1 is listed in the normal details under "User since."

Replies are listed 'Best First'.
Re^3: Dates of Monk promotion (covered)
by stevieb (Canon) on Jun 17, 2015 at 15:16 UTC

    Yep...

    echo "1-2 2009-08-29 08:54:42;2-3 2009-09-02 01:29:29;3-4 2009-09-03 0 +8:24:46;4-5 2009-09-10 08:50:28;5-6 2010-06-29 08:26:43;6-7 2010-09-0 +3 10:45:47;7-8 2012-04-01 23:00:22;8-9 2012-04-28 12:09:22;9-10 2012- +05-30 03:34:59;10-11 2014-11-30 09:34:57;11-12 2015-06-17 08:24:20" | + \ \ perl -nE '@a=split(/;/);for(@a){($a,$b)=split(/\s+(?=\d{4})/);say "$a: + $b";}' 1-2: 2009-08-29 08:54:42 2-3: 2009-09-02 01:29:29 3-4: 2009-09-03 08:24:46 4-5: 2009-09-10 08:50:28 5-6: 2010-06-29 08:26:43 6-7: 2010-09-03 10:45:47 7-8: 2012-04-01 23:00:22 8-9: 2012-04-28 12:09:22 9-10: 2012-05-30 03:34:59 10-11: 2014-11-30 09:34:57 11-12: 2015-06-17 08:24:20 # ^^^^^^^^^^ <- today of all days :)

      :)

      And here it is in SQL, should you want to use some FUNctions on the data.

      Should work in most RDBMS's, as long as they support recursive CTEs. Just replace the initial string with your own. And remove or replace "FROM Dual" with whatever works in your RDBMS.

      WITH Levels(String) AS ( SELECT '1-2 2011-11-15 07:42:33;2-3 2011-11-27 13:51:37;3-4 2011-12-0 +6 07:12:37;4-5 2011-12-09 15:28:52;5-6 2011-12-30 10:53:44;6-7 2012-0 +2-02 07:06:41;7-8 2012-03-20 06:36:12;8-9 2012-05-25 11:46:56;9-10 20 +12-08-14 06:04:53;10-11 2013-09-04 07:38:12;11-12 2014-03-26 06:30:49 +;12-13 2014-06-18 10:51:18;13-14 2014-11-13 14:14:53;14-15 2015-06-10 + 09:12:30' FROM Dual ), Split(Lvl, When, String) AS ( SELECT SUBSTR(String, INSTR(String, '-') + 1, 2), REPLACE(SUBSTR(String, INSTR(String, '-') + 03, 20), ';'), REPLACE(SUBSTR(String, INSTR(String, '-') + 23), ';', ' ') FROM Levels UNION ALL SELECT CAST(Split.Lvl + 1 AS VARCHAR2(2)), SUBSTR(Split.String, INSTR(Split.String, '-') + 03, 20), SUBSTR(Split.String, INSTR(Split.String, '-') + 23) FROM Split, Levels WHERE Split.String IS NOT NULL ) SELECT Lvl, When FROM Split;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1130824]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found