Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: DATE DIFFERENCE Post Reply Post New Topic
Author Message
MFORD
Newbie
Newbie


Joined: 13 Mar 2008
Location: United States
Online Status: Offline
Posts: 6
Quote MFORD Replybullet Topic: DATE DIFFERENCE
     Posted: 13 Mar 2008 at 6:52am
Can someone provide me with a time difference formula to calculate time of days in between random dates....ex.the amount of time in between a rec'd date and a closed date not including Saturday & Sunday?
MF
IP IP Logged
MaddMatt
Newbie
Newbie
Avatar

Joined: 18 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 17
Quote MaddMatt Replybullet Posted: 14 Mar 2008 at 6:06am
Hi,
 
The way I do it is lifted straight from the CR help files...
 
datevar d1;
datevar d2;
 
d1 := {recievedDate};
d2 := {closedDate};
 
DateDiff ("d", d1, d2) -
     DateDiff ("ww", d1, d2, crSaturday) -
     DateDiff ("ww", d1, d2, crSunday)
 
Hope that helps.
 
Cheers,
 
Matt
There are 10 types of people. Those that understand binary, and those that don't.
IP IP Logged
MFORD
Newbie
Newbie


Joined: 13 Mar 2008
Location: United States
Online Status: Offline
Posts: 6
Quote MFORD Replybullet Posted: 14 Mar 2008 at 6:29am
Thanks Matt
I have tried that-it does not work, tells me that a date is required???? I'm at a loss.
MF
IP IP Logged
MaddMatt
Newbie
Newbie
Avatar

Joined: 18 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 17
Quote MaddMatt Replybullet Posted: 14 Mar 2008 at 6:36am
Hi,
 
Sound to me like you've got DateTime fields there.  Change you formula to this:
datevar d1;
datevar d2;
 
 
d1 := date({recievedDate});
d2 := date({closedDate});
 
DateDiff ("d", d1, d2) -
     DateDiff ("ww", d1, d2, crSaturday) -
     DateDiff ("ww", d1, d2, crSunday)
There are 10 types of people. Those that understand binary, and those that don't.
IP IP Logged
MFORD
Newbie
Newbie


Joined: 13 Mar 2008
Location: United States
Online Status: Offline
Posts: 6
Quote MFORD Replybullet Posted: 14 Mar 2008 at 6:45am
That actually was accepted as a good formula then I pasted it into my details and it says bad date format string - you're so close!!!!
MF
IP IP Logged
MaddMatt
Newbie
Newbie
Avatar

Joined: 18 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 17
Quote MaddMatt Replybullet Posted: 14 Mar 2008 at 6:52am
Just checking, but you are replacing {recievedDate} and {closedDate} with your actual database fields, aren't you?
There are 10 types of people. Those that understand binary, and those that don't.
IP IP Logged
MFORD
Newbie
Newbie


Joined: 13 Mar 2008
Location: United States
Online Status: Offline
Posts: 6
Quote MFORD Replybullet Posted: 14 Mar 2008 at 6:57am
Here is the formula that I am using:
datevar d1;
datevar d2;

d1 := date({CallLog.RecvdDate});
d2 := date({CallLog.ClosedDate});

DateDiff ("d", d1, d2) -
     DateDiff ("ww", d1, d2, crSaturday) -
     DateDiff ("ww", d1, d2, crSunday)
MF
IP IP Logged
MaddMatt
Newbie
Newbie
Avatar

Joined: 18 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 17
Quote MaddMatt Replybullet Posted: 14 Mar 2008 at 7:07am
What version are you using?
There are 10 types of people. Those that understand binary, and those that don't.
IP IP Logged
MaddMatt
Newbie
Newbie
Avatar

Joined: 18 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 17
Quote MaddMatt Replybullet Posted: 14 Mar 2008 at 7:17am

Actually, it doesn't seem to matter what version you are using, the formula syntax doesn't appear to have changed at all.

A date format string is something like "ddMMyyyy", like you'd use in a cdate formula.  Are you certain that it is this formula giving you the error?
There are 10 types of people. Those that understand binary, and those that don't.
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