If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Crystal Reports > age calculation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Oct 2003
Posts: 357
Hi, it is working in CR9

Madhivanan
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On