Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Mondays between dates Post Reply Post New Topic
Author Message
MNEMS
Newbie
Newbie


Joined: 26 Oct 2013
Online Status: Offline
Posts: 8
Quote MNEMS Replybullet Topic: Mondays between dates
     Posted: 12 Feb 2014 at 5:37pm
Looking for help on a formula to determine the number of mondays (or another day of week) between two dates (determined by user defined parameter).

Any help would be appreciated.


Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Feb 2014 at 4:52am
I am guessing that the day of week is a parameter and so are the 2 dates...with that assumption, here is one way:
shared numbervar d:=0
local numbervar ind;
local datetimevar oneDay := {?startParameter};

while oneDay < {?endParameter} do (
if DayOfWeek(oneDay) = {?DayOfWeekParameter} then d:=d+1;
oneDay := DateAdd('d', 1, oneDay);
);
d;


Some of my syntax may be off, and I am making the assumption that you will convert the day of week from Monday to 2...A simple command should allow you to do that, something like:
select 'Sunday' dow, 1 dayNo
union
select 'Monday' , 2
etc...

At least that should work, if not something very close.

just a thought, hope it helps
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