Results 1 to 2 of 2

Thread: [RESOLVED] Formula problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Resolved [RESOLVED] Formula problem

    I think I'm posting in the right place. I'm using Crystal Reports XI developer with an MDB database. One field in the database is called Birthday and is a text field in the format for example, of 11/7 indicating November 7th. I need my CR report to display the monthname and day as that but I can't seem to figure out the syntax for the formula to do that. I'm trying to do this by very simple steps for my own learning ...

    Code:
    local stringvar ary;
    local numbervar dy;
    local stringvar mnth;
    
    ary = (split({Birthday},"/"));
    dy=tonumber(ary[1]);
    This results in the error that tonumber(ary[1]) is not numeric. Well .. duh ... it's a string. ary[1] gives me "false" on the report if I use it for the return.

    I seem to be misunderstanding the split ... doesn't that split the string at the delimiter - here given as "/"? To my thinking that should give an array "11" and "7" because there is only one "/" in the string. Maybe it's the way I'm trying to use those values but I can't seem to find anything helpful on the net with examples. It's probably a simple thing ...

    The idea is to end up returning monthname(mnth) + ' ' + dy ... as "November 7".

    TIA
    Ken

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Re: Formula problem

    OK ... I found the answer. I went into VS and experimented with split until I understood it. Then I went back to CR and used Basic Syntax with this:
    Code:
    dim birthday() as string
    dim mnth as string
    dim dy as string
    birthday=split({Birthday},"/")
    mnth=birthday(1)
    dy=birthday(2)
    formula=monthname(tonumber(mnth)) + " " + dy
    This is, of course, more complicated than it needs to be but I wanted to use variables to keep it all straight in my head.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width