Print Page | Close Window

Getting Last Date

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17426
Printed Date: 19 Apr 2025 at 12:57pm


Topic: Getting Last Date
Posted By: SATELE01
Subject: Getting Last Date
Date Posted: 27 Aug 2012 at 10:04am
In an SQl database I have multiple pay date records. I have two questions
 
1. How - in a formula - do I select the latest dated record?
 
2. How do I select a range of dates in a formula to get YTD data?
 
ANy help would be appreiated



Replies:
Posted By: kevlray
Date Posted: 27 Aug 2012 at 10:21am
Are asking a SQL question or a CR question?  If it is a CR question, for #1 you can't in a formula.  If you group by pay date records ascending, then the last group with have the latest dated record.  #2 I believe you can create a formula using the dateadd function that will achieve what you want (it have to be a record selection formula), Something like this {someDatefield} >= dateadd"yyyy",{?dateparm1},-1) and {someDatefield} <= dateadd("yyyy",{?dateparm2",-1}.

I hope this helps.



Print Page | Close Window