Skip to Content
author's profile photo Former Member
Former Member

Find Date of Creation in Body of String

My report has the following formual:

local stringvar s := {WEBMESSAGE.BODY_TEXT};

local numbervar x;

local stringvar ns;

for x := 1 to len(s) do

(

//Get rid of letters and a few special characters

if (NOT(s[x] IN ['A' to 'Z','a' to 'z','.','>',',',':','?'])) then

ns := ns + s[x];

);

local stringvar array str := split(ns, " ");

local datetimevar array d;

local numbervar j;

local numbervar i;

for i := 1 to ubound(str) do

(

if isdate(str[i]) then

(if Not(cdate(str[i]) IN d)

then (j := j + 1;

redim preserve d[j];

d[j] := cdatetime(str[i]);

);

);

);

if j=0

then cdate(0,0,0)

else Minimum(d);

Problem:

I have a body of text(string) which has multiple dates listed in the body. Some of the text has a Sent Date while others don't. Some of the text has multiple dates while others have 1.

Initially for the date range I was pulling it was working wonderfully. After changind some of the report selections I noticed an area that isn't correct. The below example in blue is from my report. Not sure if there is a way to get around this one????

To: Requests, Refill
> Sent: 2/22/2013 10:20 AM
>

I still need a copy of my last colonoscopy report. Including pathology on polyps removed.
2nd request. Procedure performed 11/2011 by Dr. Peck

In this example there are 2 dates. My report is pulling the last date (11/2011), but I need it to pull the date after Sent(2/22/2013).

I have another example where there isn't a sent date and there are 2 dates listed. The incorrect date is the one the report is pulling from and the correct date is the last date on the report.

Is it possible to write something to solve this issue?

Thanks for any help!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2014 at 06:25 PM

    Attached is another example where it is pulling in a date that isn't the Sent Date.

    Again, I can't thank you enough for your help on this. Everyone except you that I have worked with has told me that this is an impossible task. I believe it is possible, it's just a matter of unlocking the code.


    SAP Help 5.png (12.8 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 22, 2014 at 06:46 PM

    hi Jennifer,

    if the sent data is always the first data being added to the array, then you can change the bottom of your formula to

    d[1] instead of minimum(d)

    however, in the case where there isn't a sent date, what do you want to display...and can you provide those examples?

    -jamie

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Abhilash Kumar

      5/22 on the first line is what the formula you created for me.

      Attached is another example. This would be one where Sent: isn't anywhere in the message, so asking the system to grab the date after sent wouldn't really work with this example.

      In this example there is a partial date of 7/2011 so the formula is selecting that date as July 1, 2011 or 7/1/2011 versus the date after the providers name of 9/5/2012.

      SAP Help 4.png (5.6 kB)

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.