Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Multiple Date Range Formula Post Reply Post New Topic
Author Message
deano
Newbie
Newbie
Avatar

Joined: 22 Feb 2007
Location: United States
Online Status: Offline
Posts: 5
Quote deano Replybullet Topic: Multiple Date Range Formula
    Posted: 22 Feb 2007 at 8:59am
A saleman wants to be able to compare any random date range of this fiscal year with the same date range of last year.  I made two parameters 1. Start Date this year, 2. End Date this year.  I want to write a formula that will use those parameters and automatically chose the same date range of the pervious year.  This is what I have:  {BOKHST_LINE.DATE_TRX} IN DATE ({?STARTING DATE}) TO DATE ({?ENDING DATE}) OR {BOKHST_LINE.DATE_TRX} IN DATETIMEVALUE (({?STARTING DATE}) -1) TO DATETIMEVALUE (({?ENDING DATE}) -1)
The first part works but I get no data for the previous year????  I know the formula is wrong  but don't know what to do???
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 22 Feb 2007 at 2:04pm
The error in the formula is that you are just subracting "-1" from the date field. This just subtracts one day from the date. To get last year's date from a given field, use the Crystal Reports DateAdd() function. You can modify the range to use this formula instead:

IN DateAdd("yyyy",-1,{?STARTING DATE}) TO DateADD("yyyy",-1,{?ENDINGDATE})



Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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.035 seconds.