Solved

How do I retrieve the most current date value?

Posted on 2008-10-29
3
615 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 100 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 100

Assisted Solution

by:mlmcc
mlmcc earned 100 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 175 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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