Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date Comparison Formula Post Reply Post New Topic
Author Message
heme3
Newbie
Newbie


Joined: 16 Jul 2008
Location: United States
Online Status: Offline
Posts: 1
Quote heme3 Replybullet Topic: Date Comparison Formula
    Posted: 16 Jul 2008 at 7:18am
I'm using CR8, the following formula gives me 3 date ranges based on the # of days in the "current period" (for example: current period 1 to 10 July 2008, prior period 22 Jun to 1 July 2008, and last year period 1 to 10 July 2007)
 
--------

({CRIMES_ALLV.DATEOCC} in dateadd("d",-(datediff("d",{?StartDate},{?EndDate})),{?StartDate})to{?StartDate}
or
{CRIMES_ALLV.DATEOCC} in dateadd("yyyy",-1,{?StartDate}) to Dateadd("yyyy",-1,{?EndDate})
or
{CRIMES_ALLV.DATEOCC} in {?StartDate} to{?EndDate})
 
--------

This part of the formula: ({CRIMES_ALLV.DATEOCC} in dateadd("d",-(datediff("d",{?StartDate},{?EndDate})),{?StartDate})to{?StartDate}

gives me the prior period 22 Jun to 1 July, but I need it to give me 21 Jun to 30 Jun (so that I'm not overlapping the 1 July date in my comparisons.

Any tips or clues out there?
heme3
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.