Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: ThisWeek / Month Post Reply Post New Topic
Author Message
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Topic: ThisWeek / Month
    Posted: 04 Mar 2010 at 6:33am
Hey guys.
 
Normaly i work for a lot of my reports with 2 parameters
StartDate  and StopDate
now i need for some reports a couple of versions of the same report
but i want to switch the 2 parameter date's with builed in dates
1 for the current Week and in the other report for the current Month
 
The report contains sales information from our shops
 
{Alle verkoop multi filiaal.h_datum} >= {?StartDate} AND
{Alle verkoop multi filiaal.h_datum} <= {?StopDate}
this is my current record selection  and i would like to change the start and stop date part to a static value
 
monday / tuesday /wednesday / ...
so if i run the report on a thursday i want the results from monday to thursday
 
For the stopdate i can use currentdate value but for the startdate i'm a bit stuck
for the week i don't care if it's the date from monday or sunday but for the month it's the first day of the month ofcourse.
 
Is there a CR command that gives me those date's ?
 
 
Greetings
 
Adam
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Mar 2010 at 6:57am
{Alle verkoop multi filiaal.h_datum} in MonthToDate
 
Datepart('ww',{Alle verkoop multi filiaal.h_datum})=datepart('ww',currentdate)
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 12 Mar 2010 at 6:04am
Hi Dblank, this is working like a shard with only 1 negative point
i forgot to say that there is info in that file for the last 4 years
so now i have info of sales in that week in the last 4 years while i only want this year :p
 
i added another AND where i said {alle verkoop multi filiaal.h_datum} > date(01/01/2010)
I think this is the correct solution ?
 
Adam
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Mar 2010 at 6:47am
That would be a temporary solution. I would make it move with today's date so you do not have to worry about it come next year..
Maybe:
{Alle verkoop multi filiaal.h_datum} in last7days
and
Datepart('ww',{Alle verkoop multi filiaal.h_datum})=datepart('ww',currentdate)
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 12 Mar 2010 at 7:13am
Hey DBlank,
 
can't i do somthing like and dateware('YYYY',{alle verkoop multi filiaal.h_datu}) = dateparrt('yyyy',currentdate)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Mar 2010 at 7:24am
Yes you could compare the yearpart but if you happen to run this weeks report at the begiining of jan it can exclude part of your week that fell into last year. I know it would be rare but why risk it when you have just as easy of a solution that won't leave data out accidently.
if you use the last7days syntax it will not matter as it has to meet both conditions to get into the report, the most days you ever have is 7 so this combo works more consistently.
FYI - There might be an actual syntax for this but I cannot find it as there is LastFullWeek which gives you the previous week but I do not know what works for the current week hence my other suggestions...


Edited by DBlank - 12 Mar 2010 at 7:25am
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 12 Mar 2010 at 7:29am
i used your last sollution now and it works like a charm
 
tnx a lot for the fix !!
 
Adam
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Mar 2010 at 5:07am
Hey Adam - just came across this and thought you might want it for the future...I knew there was a shortcut for the current week but could not remember what it was...
 
{Alle verkoop multi filiaal.h_datum} in WeekToDateFromSun


Edited by DBlank - 23 Mar 2010 at 5:07am
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.