I am working on reports that need to be run daily, weekly and Monthly. Preveously they were written in MS Access (I am not sure if there is a way directly conver into Crystall since I am fairly new using Crystal). So I am trying to display activities records for the last seven days, starting Monday and ending Sunday as a weekly reports.
Assuming you are trying to get the weekly report to automatically recognize today's date and run the report for the last full week, you can use a condition such as:
--------------------------------------------------------
DatePart("ww", {your_date_field}, crMonday) + 1 = DatePart("ww", currentdate, crMonday)
--------------------------------------------------------
Just be sure to enhance it with the logic needed to deal with cases where today's data is in the 1st week of the year.
Cheers,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
Here is the formula that calculates a Monday to Sunday week. Create the formula then group on it with your "section will be printed" set to Day if you want to do a weekly grouping.
datevar adjusted;
datevar date1:={your.date.field};
if dayofweek(date1)=1 then adjusted:=date1- 6
else
adjusted:=date1-dayofweek(date1)+2
If you want to only see data for the current week (Monday to Current day) your select expert would be:
{your.date.field} in (currentdate - dayofweek(currentdate)+2) to (currentdate)
If you want to see last week's data from Monday to Sunday your select expert would be:
{your.date.field} in (currentdate - dayofweek(currentdate)-5) to (currentdate - dayofweek(currentdate))
IF you want this months data:
datediff("M",{your.date.field} ,currentdate)=0
If you want one month back :
datediff("MM",{your.date.field} ,currentdate)=1
If you want last month and this month:
datediff("M",{your.date.field} ,currentdate)<=1
If you want 3,2, and 1, but not this month's
datediff("M",{your.date.field} ,currentdate) in 1 to 3 Mike
found this posting when searching for current week related issues. My problem is how do I report on the whole of the current week. Management would like to see the capacity for the current week, so on Monday the weeks capacity might be at 90%, by tue it might drop to 80%, by wed shoot up to 99%, etc. So although the one formula shows how to report on current week (monday to current day), how do I change this formula to show monday to sun of current week only?
I need to do something similar (I think). From a single date from a parameter (which runs daily stats) I need to calculate the beginning of the week (a Monday), the beginning of the month, the beginning of the fiscal quarter (July through Sept., Oct. through Dec., etc) and the beginning of the year so that I can report cummulative stats for those time periods (beginnings to my entered date). Can someone point me in the right direction (with a few basic examples) please??
Take a look at DatePart and DateAdd functions, maybe write a test report to work out exactly what they do. You can do a formula field to get year as a datepart, and then use another formula field to pick up the start of year:
Date (@Yearpart, 1, 1)
If you need any more advice, please start a new thread, since it is a different topic. Also try a search, you may find the exact code already laid out somewhere.
It helps to give your Crystal version, since newer versions have extra options, and some extra problems. I use Crystal 8.5
I am trying to get a report based on the dates that I will send as parameter. I can select any date range lets say sdt_dateentered = '08/01/04' and sdt_dateend = '09/03/04'.So when I enter this date the report should be in formatt of multiple weeks(for each week from Aug to Sept.), and each week seperatly marked.
Now if I enter only sdt_dateentered = '10/04/04' and sdt_dateend = '10/08/04', the report should have data for one week, marked with that week only.
I have my report but I can't make it show data as a week or each week.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.