Re: date format
- To: mathgroup at smc.vnet.net
- Subject: [mg75157] Re: date format
- From: Albert <awnl at arcor.net>
- Date: Wed, 18 Apr 2007 05:13:08 -0400 (EDT)
- References: <f015bp$9sk$1@smc.vnet.net>
Hi, > Form the following date format > > 04/Dec/2006:19:54:02 > > could you please show me how to get the following representation {day, > month, year, hour, minutes, seconds} - so exactly the same as for > Date[] > This is one way to do what you want: monruls = { "Jan" -> 1, "Feb" -> 2, "Mar" -> 3, "Apr" -> 4, "May" -> 5, "Jun" -> 6, "Jul" -> 7, "Aug" -> 8, "Sep" -> 9, "Oct" -> 10, "Nov" -> 11, "Dec" -> 12 }; Map[ ToExpression, StringSplit[datestr, ":" | "/"] /. monruls ][[{3, 2, 1, 4, 5, 6}]] it splits the string at : and /, then replaces the month with numbers, makes all the remaining string to numbers with ToExpression and finally sorts the entries as they appear in the Date format. If you really need that, you could turn the last entry for the seconds into a real with N, with the above code, it still is an integer which I think should be o.k. for most cases... hth, albert