?
Solved

Crystal Reports - Display Date Range on Report

Posted on 2013-01-16
5
Medium Priority
?
3,124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 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 44

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 101

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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