Solved

How do I retrieve the most current date value?

Posted on 2008-10-29
3
612 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now