Solved

How do I retrieve the most current date value?

Posted on 2008-10-29
3
616 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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…
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 …

710 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