MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: split a number to Date format

  • To: mathgroup at
  • Subject: [mg124257] Re: split a number to Date format
  • From: "Hans Michel" <hmichel at>
  • Date: Sat, 14 Jan 2012 17:13:32 -0500 (EST)
  • Delivered-to:
  • References: <>

The nice thing about Regular Expression is that it has been around a while
now and there is a good place to go find tried, tested and sometimes well
documented pattern matching strings. I was very pleased when WRI introduced
Regular Expression in Mathematica. Even with Mathematica's (in their words
"powerful") pattern matching, I learned Regular Expressions some 6-7 years
before Mathematica came out. So I feel more comfortable around Regular
Expressions. As far as I know, I don't see an equivalent publically
available library of Mathematica pattern matching.

So I found a Regular Expression on this site

This pattern match will match ISO 8601 date time format with or without the

([0-5]{1}\\d{1})(?::)?([0-5]{1}\\d{1})"] -> "20$1,$2,$3,$4,$5,$6"]

d = "111205020000";

You may also translate the RE pattern matching to the faster Mathematica
String matching. I don't know how RE is implemented in Mathematica but I
would think it is probably slower than the older built in matching

Also note that a 2 digit year poses a problem of what to use when the 2
digits is greater than current year.  When do you use "19" or "20" to
designate century?

The result is a list but it needs further processing to get to a DateList.
You asked for help. This is what I could do with the time I had.

I will come back to it for a complete solution if time permits.


-----Original Message-----
From: Derek Martin [mailto:cdmartin at] 
Sent: Saturday, January 14, 2012 1:54 AM
To: mathgroup at
Subject: [mg124257] split a number to Date format

I have experimental data in spreadsheet format.  The first column is a time
stamp in the format 111205020000.  
If I could parse or split the number 111205020000 into {11,12,05,02,00,00}
and replace the first 11 with 2011, the Date commands would work fine. I can
do the replacing, but am having difficulty seeing how to split the number
into  {11,12,05,02,00,00}.

DateString[{2011, 12, 05, 02, 00, 00}] gives
"Mon 5 Dec 2011 02:00:00"

Any help to convert my number to the right Date format would be appreciated.
I am using Mathematica 8.

Thanks in Advance

  • Prev by Date: Re: split a number to Date format
  • Next by Date: Re: split a number to Date format
  • Previous by thread: Re: split a number to Date format
  • Next by thread: Re: split a number to Date format