Re: Converting Dates to Mathematica Format
- To: mathgroup at smc.vnet.net
- Subject: [mg52096] Re: Converting Dates to Mathematica Format
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Wed, 10 Nov 2004 04:46:01 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 11/9/04 at 1:37 AM, gregory.lypny at videotron.ca (Gregory Lypny) wrote: >Is there a simple way to convert dates imported as "Day/Month/Year" >to the Mathematica format of {Year, Month, Day}? My dates are one >column in a matrix of data. Mathematica appears to be treating >them as strings. I used StringReplace to turn 15/10/2004 to >15,10,2004 but it remains a string, of course. >Any suggestions would be most appreciated. My alternative is to >import all of the dates as 20041510 so the ordinal ranking is >maintained by date calculations would not be possible. The following will do what you want FromDate[Flatten[ {Reverse@ToExpression[ "{"<>StringReplace["15/10/2004",{"/" -> ","}]<>"}" ], 0, 0, 0}]] 3306787200 ToDate[%] {2004, 10, 15, 0, 0, 0.} I'll leave it to you to decide whether this method should be called simple or not. -- To reply via email subtract one hundred and four