Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Date and days to exclude weekend Post Reply Post New Topic
Author Message
CrystalGirl
Newbie
Newbie


Joined: 22 Feb 2015
Online Status: Offline
Posts: 36
Quote CrystalGirl Replybullet Topic: Date and days to exclude weekend
    Posted: 25 May 2016 at 10:10am
Hello,

in my report I have two parameters, @Startdate and @EndDate.

My question is, how do I substract from my @Startdate and @EndDate

and just to get weekdays only? Can Crystal handle this thru the formula?

I can get the total days if I substrack between @Startdate and @EndDate

but I need to get just the weekdays.

For example

if my @Startdate = 05/18/2016 and my @EndDate = 05/25/2016 the the total

days I am expecting to see is: 5 days instead 7 days.


Anyone knows how to write this formula?

Edited by CrystalGirl - 25 May 2016 at 10:10am
IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 26 May 2016 at 12:30am
You have an example of doing exactly what you ask for.
This a copy & paste from the CR help for the DateDiff function:

"For example, suppose you want to calculate the number of days between the order date and ship date, excluding Saturdays and Sundays: "

Local DateTimeVar d1 := {Orders.Order Date};
Local DateTimeVar d2 := {Orders.Ship Date};
DateDiff ("d", d1, d2) - DateDiff ("ww", d1, d2, crSaturday) - DateDiff ("ww", d1, d2, crSunday)
IP IP Logged
CrystalGirl
Newbie
Newbie


Joined: 22 Feb 2015
Online Status: Offline
Posts: 36
Quote CrystalGirl Replybullet Posted: 26 May 2016 at 3:27am
Valert16,

That's really cool! I am new in Crystal Reports. You are good!
IP IP Logged
CrystalGirl
Newbie
Newbie


Joined: 22 Feb 2015
Online Status: Offline
Posts: 36
Quote CrystalGirl Replybullet Posted: 28 Jun 2016 at 1:25pm
Valert16,

Do you know how to update the above working formula if I want to add to exclude the Holiday as well?

Thanks Valert16

Edited by CrystalGirl - 28 Jun 2016 at 1:35pm
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.