Solved

Crystal Reports - Display Date Range on Report

Posted on 2013-01-16
5
2,863 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 42

Accepted Solution

by:
zephyr_hex 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 42

Expert Comment

by:zephyr_hex
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now