View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rajendra Rajendra is offline
external usenet poster
 
Posts: 11
Default Extracting dates from a String

On Oct 7, 11:22 pm, "Rick Rothstein"
wrote:
I think you need to give us a little more information about the structure of
these text strings of yours. Is the month name **always** spelled out? Is
the year **always** a 4-digit number? Is the only character between date
parts the space character (that is, a comma is **never** used between the
day and the year)? Is the word "to" **always** used to separate the two
dates and, if not, can the text separating them be more than one word long?
Could there other numbers before the first date?
--
Rick (MVP - Excel)

"Rajendra" wrote in message

...
On Oct 7, 9:03 pm, Al wrote:



Try for start date:
=MID(A1,FIND("period",A1)+7,(FIND("to",A1))-(FIND("period",A1)+8))


Stop date:
=MID(A1,FIND("to",A1)+3,(FIND("-",A1))-(FIND("to",A1)+4))


HTH


"Raj" wrote:
Hi,


Cells in Column A have strings of the following type:
eg A1:
Billing for the period March 14 2009 to March 13 2010 - Order dated
April 01 2009
In B1 I want the date : 14-Mar-2009
In C1 I want the date: 13-Mar-2010
(to elaborate, only the first two dates in the string need to be
extracted, third and subsequent dates in the string to be ignored)


Thanks in advance for the help.


Regards,
Raj- Hide quoted text -


- Show quoted text -


Thanks. While that worked right for the given string, it did not work
for all the rows as the strings are composed differently. The word
"period" does not precede the first date at all times nor does the "-"
suceed the second date. Is there a way to extract the first two dates
by looking for the first and second occurrences of the standard "mmmm"
months in the String and then compute the dates based on the position
of those strings?

Regards
Raj


The month name is almost always spelled out in full : January,
February and so on. There are are a few instances of Jan or Feb in the
data.
Year is always a 4 digit number
The separator between dates is always either "to" or "To" or
"tp" (misspelling)
There are no numbers before the first date.
The dates are of the type: (actually more than I initially thought):
November 24th 2008 To May 23rd 2009
12th November 2008 To 11th November 2009
June 20 2009 to June 19 2010
1st Dec 08 tp 31st Dec 08

Thanks and Regards,
Raj