Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: sorting dates in YYYYMMDD format

by AnomalousMonk (Monsignor)
on Jul 04, 2013 at 18:41 UTC ( #1042503=note: print w/ replies, xml ) Need Help??


in reply to Re^4: sorting dates in YYYYMMDD format
in thread sorting dates in YYYYMMDD format

Yes, but the real strings that have to be sorted may not be that easy ...

Yes, but do you see that part of the point hdb was making was that  /(..)(..)(....)/ does not extract anything meaningful from a string like  '20130401' because the year winds up as '20' and '13', and the month and day fields wind up stuck together as '0401'. As hdb points out, this only works because all this mess is immediately stuck back together to form the original string — which is then sorted lexicographically, as any number of monks have recommended. The fact that learner@perl specifies test data in the  @dates array in YYYYMMDD format and has a subsequent comment
    @dates;  # DD-MM-YYYY
further suggests that he or she does not firmly grasp what is going on.

BTW, a date in the format  '2012-04-01' or  '2012/04/01' or with any other delimiter character or characters will lexi-sort perfectly well as it stands as long as the delimiter(s) at each position are constant!


Comment on Re^5: sorting dates in YYYYMMDD format
Select or Download Code
Re^6: sorting dates in YYYYMMDD format
by Dallaylaen (Scribe) on Jul 05, 2013 at 03:55 UTC
    You are absolutely right. I've seen a need for extra transformation but there wasn't any.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2014-07-23 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls