Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How to set up Title with Start and End Dates Post Reply Post New Topic
Author Message
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Topic: How to set up Title with Start and End Dates
     Posted: 15 Jan 2009 at 2:50pm
Good Day,
 
I am currently creating a report that is a Year to Date report of incidents from our incident management system. The report will look at incidents on a month to month basis and then report back the total number of incidents per month on a year to date basis.
 
I am trying to put the start and end date of the report in the Report Header, but I am running into some difficulty.
 
The title I am trying to put in has the formula:
 
ToText ({@StartOfYear}) + " to " + ToText ({@RunDay})
 
When I run the report, the title shows as January 1.00, 2,008.00 to January 15.00, 2009.00
 
The formula for the @StartofYear is:
 
//
Shared StringVar RunYear:= "";
//
If Month(currentdate) = 1 Then
    RunYear := ToText( Year( currentdate()) - 1 ) 
Else
    RunYear := ToText ( Year(currentdate()) );
//
MonthName (Month (DateTime (2007, 01,01))) + " " + ToText (Day (DateTime (2007, 01,01))) + ", " + RunYear
 
 
The formula for the @RunDay is:
MonthName (Month (CurrentDate)) + " " + ToText (Day (CurrentDate)) + ", " + ToText (Year (CurrentDate))
 
What I would like it to read would be:
January 1, 2009 to January 15, 2009.
 
And, if I ran the report on say, March 1st, I would want the title to read:
 
January 1, 2009 to March 1, 2009
 
What am I doing wrong?
 
Thanks!!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Jan 2009 at 7:31pm
with your totext from a number you can trim the decimals and get rid of comma's by totext(field,0,'') - the 0 tells it how many decimal points to use (as you see it defaults to 2) and the '' tells it not to use the comma in you thousand indicator (2,008 to 2008).
Example:

MonthName (Month (CurrentDate)) + " " + ToText (Day (CurrentDate),0) + ", " + ToText (Year (CurrentDate),0,'')

Or you could use the date functions like:
totext(currentdat,"d")
totext(currentdate,"yyyy")


Edited by DBlank - 15 Jan 2009 at 8:37pm
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