Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Datediff on a datefield parameter Post Reply Post New Topic
Author Message
bash
Newbie
Newbie


Joined: 30 Jan 2013
Online Status: Offline
Posts: 12
Quote bash Replybullet Topic: Datediff on a datefield parameter
     Posted: 19 May 2013 at 4:09am
Hi,
In my CRXI report, a date range is defined through parameter prompt. Is there a way to do the datediff function on this field?
 
Here is the example:
{?mydaterange} is taken from ({startdate}) and ({enddate}). It is defined in parameter. How do I run datediff function on the {?mydaterange}?
 
Thanks for the help.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 May 2013 at 9:01am
why not run datediff against the parameters instead?

Is myDateRange an array or a string or a date.

If it is an array, you could do something like:
datediff("day", {?mydaterange}[0], {?mydaterange[1]})
or something like that...I haven't done this exact process so my syntax may be off a bit.

HTH
IP IP Logged
bash
Newbie
Newbie


Joined: 30 Jan 2013
Online Status: Offline
Posts: 12
Quote bash Replybullet Posted: 20 May 2013 at 8:12pm
Hi
Thanks for the reply. I did another way as following:
 
Local DateTimeVar d1 := minimum ({?Period_Range});
Local DateTimeVar d2 := maximum ({?Period_Range});
DateDiff ("d", d1, d2) -
     DateDiff ("ww", d1, d2, crSunday)
 
It did work for me. however it didnot include the last day in the d2. any suggestion why it is?
 
Thanks again for your input
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