Solved

Crystal Reports - Display Date Range on Report

Posted on 2013-01-16
5
2,960 Views
Last Modified: 2013-01-16
I have a report that I am wanting to automate to run every week.  The report uses "is in the period" LastFullWeek in the Select Expert Record.

How can I display this date range on my report?  

Since the report is going to be setup to run automated in Business Objects, I don't think I can use a parameter field....or at least I can't figure out how to do is successfully.

Originally, I had parameter fields in the report and I could choose the date range.  Then I was able to use a formula to display the date range as a header.  But since, I am setting this up in Business Objects to run automated, I changed my record selection to not use the date to and from parameter field and I'm using the LastFullWeek field.
Ratio-Report---Automated.rpt
0
Comment
Question by:ITworks
  • 2
  • 2
5 Comments
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) earned 500 total points
ID: 38783352
you can use a formula to display the date range based on the date the report is automatically run.  the date the report is run is "today", and you can calculate the date of "one week ago".

Start Date:  7 days ago
End Date: today

formulas:
Start Date:
dateadd("d",-7,today)

Today:
today

To show the range, you could create a formula as follows:
"Date Range: " & totext(dateadd("d",-7,today)) & " - " & totext(today)

And if you want to trim off the time stamps, you can do:
"Date Range: " & totext(dateadd("d",-7,today),"MM/dd/yy") & " - " & totext(today,"MM/dd/yy")
0
 
LVL 4

Author Comment

by:ITworks
ID: 38783632
I'm confused.......If I set it to automatically run today, wouldn't this show me data from -7 days ago until today?   I want it to show data from the last week Sunday through Monday.  I need to schedule the report later in the week like on a Wednesday to allow Supervisors to make corrections.  This report is showing labor ran.  I need to allow time for Supervisors to make corrections before running the report.

I meant to say I want it to show data from last week Sunday through Saturday.
0
 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 38784632
sorry, i misunderstood.

if you'll always run the report on Wednesday and want data for the previous Sun thru Mon, you could just use dateadd without testing for the value of the day of the week.  you know how many days back the first day and last day of your range are when compared to Wednesday.

but that's a rather inflexible approach... what if you want to run the report on Thursday?

one way to do this is to find the date of last Monday.  in Crystal, Monday is day "2".
if DayofWeek(today)=2 then dateadd("d",-7,today)  //if today is Monday, get the previous Monday
else if DayofWeek(dateadd("d",-1,today))=2 then dateadd("d",-1,today)
else if DayofWeek(dateadd("d",-2,today))=2 then dateadd("d",-2,today)
else if DayofWeek(dateadd("d",-3,today))=2 then dateadd("d",-3,today)
else if DayofWeek(dateadd("d",-4,today))=2 then dateadd("d",-4,today)
and so on...

so now you have the date of the previous Monday.  you can use that to find Sunday.
dateadd("d",-8,formula_to_find_Monday)
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 38785479
There is a much easier method that works regardless of when you run the report during the week.

"Date Range: " & totext(Minumum(LastFullWeek),"MM/dd/yy") & " - " & totext(Maximum(LastFullWeek),"MM/dd/yy")

mlmcc
0
 
LVL 4

Author Comment

by:ITworks
ID: 38785484
Thank you, mlmcc.   I searched EE for answers that you helped with.   I actually found something similar on EE where you answered someone's question before.  It was for Last Month.....but I was able to figure out to replace it to the Last Full Week.  That is what I used on my report.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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