Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: dayofweek explanation Post Reply Post New Topic
Author Message
Guests
Guest Group
Guest Group


Joined: 09 Nov 2006
Online Status: Offline
Posts: 0
Quote Guests Replybullet Topic: dayofweek explanation
     Posted: 05 Mar 2012 at 8:02am
Could someone explain exactly what the formula below means.  I am working on a report that was written by someone else.  I need to change the report to report on closed issues from the prior Monday to Sunday and send the report on the following Monday.  However, if the report is run on any other day, it should only report on the prior Monday's issues through the upcoming Sunday. 
 
This formula is for issues from the prior Thursday to Wednesday and sends the report out on Friday.
 

if DayofWeek(currentdate,crFriday) = 1 then

currentdate - DayofWeek(currentdate,crFriday)-7

else currentdate - DayofWeek(currentdate,crFriday)

 

if DayofWeek(currentdate,crFriday) = 1 then

currentdate - DayofWeek(currentdate,crFriday)-1

else currentdate - DayofWeek(currentdate,crFriday)+6

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Mar 2012 at 8:12am

it is saying if today is friday (if DayofWeek(currentdate,crFriday) = 1 )

then subtract 8 days from today (currentdate - DayofWeek(currentdate,crFriday)-7)
else subtract the day of the week value (friday=1) from today (else currentdate - DayofWeek(currentdate,crFriday))
IP IP Logged
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