Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I retrieve the most current date value?

Posted on 2008-10-29
3
Medium Priority
?
620 Views
Last Modified: 2012-05-05
Im working on a report in Crystal Reports XI, and I need to retrieve values from a field titled JE_SERVICE_CODE, which is a string field type.  Each JE_SERVICE_CODE value has a corresponding date value (the date it was entered) which is stored in a field titled JE_DATE_STAMP (both fields reside in the same table).   Is there a way to retrieve the JE_SERVICE_CODE value that is associated with the most current date value?  
0
Comment
Question by:jsmith08
3 Comments
 
LVL 14

Assisted Solution

by:LinInDenver
LinInDenver earned 300 total points
ID: 22836994
Hi there - depending on what you are looking for, it would be possible to create a parameter for the date field IF you know the date you are looking for. Or, you could filter the report to alway return today's date.

If it isn't quite that simple, I would start by sorting Descending on the date field, and see if I can do some conditional suppression on details not equal to the max value.

I don't know if this will help, but good luck!
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 300 total points
ID: 22854319
One way would be to sort the data descending by date and display the first record.

mlmcc
0
 
LVL 26

Accepted Solution

by:
Kurt Reinhardt earned 525 total points
ID: 22855753
This is a pretty common requirement (show me the most recent/current records), but it's not handled very elegantly in Crystal Reports.  Before we can truly provide a solution, we need some questions answered:

1)  Are you reporting against a SQL-based database (SQL Server or Oracle, for example)?
2) Do you want to do this in SQL or within Crystal?

If you're trying to do this in Crystal Reports AND are reporting against a SQL-based database, the most efficient method is to create a SQL Expression field that identifies the most recent records.  You can then filter the report based on the expression field.  The benefit to doing this is that you pull only the records you need from the database rather than pulling all records and then suppressing them after the fact with conditional suppression or group select formulas.

I've attached a presentation with an example, starting on Slide 29.

If you want to do this entirely within SQL (if you're reports based on a view or command, for example), then we can help with writing a subquery for you.

If you need to do this in Crystal Reports AND are reporting against a PC-based database (like Access), then you probably need to sort records by date in descending order then either conditionally suppress all records where the date <> a formula for the max date value or do pretty much the same thing within the group selection criteria.
The-Power-and-Possibilities-of-S.pdf
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question