Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date Stamp Post Reply Post New Topic
Author Message
Kathleen
Newbie
Newbie
Avatar

Joined: 31 Dec 2007
Location: United States
Online Status: Offline
Posts: 17
Quote Kathleen Replybullet Topic: Date Stamp
     Posted: 31 Dec 2007 at 6:16am
I am a new Crystal User and have been assigned several reports.  I need some help.  First, I need the report to print the date of the information in format MM/YY at the top - not the date the report is being printed, but the date of the information - the date we are using in the Select Expert to get the previous month's information (or whatever month the manager's want).  How can I get that date in that format?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Jan 2008 at 11:18am
(I'm assuming that you are using a parameter to query the user about which month they want to print) You can format dates using the CStr() function. For example, if your parameter was called DateToPrint, then the code would be:
CStr({?DateToPrint}, "MM/yy");

On a side note, if you have the option Save Data With Report turned on, then the DataDate and DataTime funtions tell you when the report data was last refreshed.

I have all the date/time functions fully documented in Chapter 6 of my book Crystal Reports Encyclopedia. Since you're new to Crystal Reports, getting a copy will most likely make it much easier for you to learn Crystal Reports.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Kathleen
Newbie
Newbie
Avatar

Joined: 31 Dec 2007
Location: United States
Online Status: Offline
Posts: 17
Quote Kathleen Replybullet Posted: 02 Jan 2008 at 6:44am
I used the formula as written below
 
CStr (DataDate, "MM/yy")
 
I do get a date to appear, however, it is not the date of the data.  I am getting the date as 01/08.  The data I am using is dated 11/07 - as in my Select Expert I am using NDate is between 20071101 and 20071130.  It is the date of 11/07 that I want to print at the top of my document.
 
Is there some other command for DataDate?
 
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 02 Jan 2008 at 7:36am
How are you telling the report to print the 11/07 data?  Are you hard-coding it into the Select Criteria?  If so, the simplest solution is to hard-code the date in the header.

If you have a moving window (e.g., "within the last 30 days" or "last full quarter"), then there are a couple ways to do it.

The simplest, I've found, is to use Minimum({MyReport.MyDate}).  This will return the first date found in the report.  Usually, this is what you are looking for, especially as you are "rounding" it to the month level.  However, occasionally, this can produce odd results.  For instance, if you happen to have 10/31/2007 included, because it was actually a four-week period instead of a true month, this would return "10/07" even if most of the data is "11/07".  Also, if you are doing it by day, and you happen to not have any data for the first day, it goes by the first day you have data, not necessarily the first day in your selected range.

A better option is to simply reproduce your logic in another formula, and use that to generate a date.  Generally, you would put together your formula to look something like:
{MyReport.ReportDate} IN DateAdd("d",-90,CurrentDate) TO DateAdd("d",-60,CurrentDate)

Then, your field in your header might look something like:
CStr(DateAdd("d",-90,DataDate),"MM/yy")


IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum