Results 1 to 4 of 4

Thread: age calculation

  1. #1
    Join Date
    Dec 2004
    Posts
    4

    age calculation

    I am using crystal reports 8.5 and I am trying to show an age on a report I have this age formula

    whilereadingrecords;
    DateVar Birth:= cdate({Pets.PtBirthDate});


    if ((month(currentdate) * 100 + day(currentdate)) >= ((month(Birth)*100) + day(Birth)))
    then year(CurrentDate) - year(Birth)
    else Year(CurrentDate) - Year(Birth) -1;

    when I check the formula it says there are no errors but when I preview the report it tells me that there is a bad date format string.

    the date is stored as a string[10], but there are dates in there as 1/1/04 01/1/2004, and every combination of those that you can think of. Do I need a piece of code to check for these things. Not sure what to do next.Does anyone have any suggestions for me? Thanks in advance

    Jesse

  2. #2
    Join Date
    Oct 2003
    Posts
    357
    Hi, it is working in CR9

    Madhivanan

  3. #3
    Join Date
    Dec 2004
    Posts
    4

    Question

    Not sure Why it works in 9 but not in 8.5. It does work for some clients in our database but for others it does not. I was assuming it was how some of the dates were entered. Some of the staff here put dates in as 01/01/2004 while others enter them as 1/1/04 and still otheres think its ok to enter as
    1-1-04 with dashes instead of slashes. When the report encounters these different formats can it handle it automatically or is there a piece of code that I need to enter in to the formula for it to work. Another thing I thought that might be effecting this is the fact that the date is stored as a string but not sure if that matters or not.

    Jesse

  4. #4
    Join Date
    Dec 2004
    Posts
    4

    Angry

    Ok it works in 8.5 but I dont understand what happened The report was working so I copied the formula from one report to another report that I want to calculate the age of clients on. Now the first report no longer works I get a bad date format string when I preview the report in crystal. but the same exact formula works in the second report. Does any one have any input as for the reason of this.

Posting Permissions

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