Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Find maximum date in string value Post Reply Post New Topic
Author Message
verniqueb
Newbie
Newbie


Joined: 04 May 2009
Location: United States
Online Status: Offline
Posts: 12
Quote verniqueb Replybullet Topic: Find maximum date in string value
     Posted: 09 Jun 2009 at 9:25am
I need help in finding the max date on a string field.  Here is the formula I have so far:
WhilePrintingRecords;
DateVar X;
x:=CDate({InputMaster.DateOnMaster});
maximum(X)
 
The date is stored in Dateonmaster field as string.  I would like to convert this string to date format find the Maximum date value and display is on the report page header.
 
Your help is greatly appreciated.
VB
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Jun 2009 at 6:17am
I would suggest a subreport with a formula.  Your formula is almost there.  Since Crystal works on a row by row basis, the maximum function will always return the same value.  I would add a shared datevar like:
shared datevar maxDate;
DateVar X;
X:=CDate({InputMaster.DateOnMaster});
if x>maxDate then
  maxDate := X
 
I would put this in the details section of the subreport, then suppress the subreport's header and detail sections.
 
in the report footer, I would place a formula that displays maxDate.
 
On second thought, I would place the subreport in the main report REPORT HEADER, so that it is run ONLY once.  Suppress all sections of the subreport (you just want it to calculate the date) then I would display the formula that displays the date in the page header.
 
HTH
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 10 Jun 2009 at 7:32am
Hi
 
Can you post sample data for the Date,edit the  formula use
 
Maximum({table.datefield})
 
hope that works....
 
place the formula in Page Header right click format field and select the date format you want.
 
cheers
Rahul


Edited by rahulwalawalkar - 10 Jun 2009 at 7:33am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Jun 2009 at 10:56am
Since it is a string, depends on how it is formatted.  yyyymmdd will work, but ddmmyyyy or mmddyyyy won't
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum