Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: date ranges multiple records Post Reply Post New Topic
Author Message
iselsrock36
Newbie
Newbie
Avatar

Joined: 22 Oct 2009
Location: Canada
Online Status: Offline
Posts: 4
Quote iselsrock36 Replybullet Topic: date ranges multiple records
    Posted: 22 Oct 2009 at 11:58am
Hi everyone. I'm new to the boards so be gentle. I just got a job working for the government as a report writer so I'm new to this stuff.
Anyway I'm building a report and i have a problem. I have a report where I have to report on peoples income and I'm have a date range problem
-------------------------------------------------------------------------
child supplement  $318   sep/1/2008/      jul/31/2009
 
student loan  $805  mar/1/2008   feb/28/2009--(only need jan to feb)
student loan  $1098  mar/1/2009  jan/1/2010---(only need mar to april)
---------------------------------------------------------------------------
Now I set up date prams and selected jan1/2009 to april30/2009
Im doing totals on the months selected for each record.so i did a datediff
DateDiff("m", {?FromDate}, {?ToDate}+1)
to get the number 4 and then multiply to the total to give me a 4 month total.so for the child supplement im getting a total of $1272 which is right but for the other two records(student loan) I only need two months out of each record to get the total but my datediff is always calculating 4.does anybody have any suggestions that could help me.maybe im using the wrong function or setting up my forumla wrong. the date ranges could change also so static numbers in my forumula will not help.have to distinguish when there are different date ranges.


Edited by iselsrock36 - 22 Oct 2009 at 12:02pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Oct 2009 at 1:59pm
local datevar endDate:={?ToDate};
if {table.field} < {?ToDate} then
  endDate := {table.field};
 
DateDiff("m", {?FromDate}, endDate+1)
 
this is what I would try, this way the ending number of months can be dynamic.
 
HTH
IP IP Logged
iselsrock36
Newbie
Newbie
Avatar

Joined: 22 Oct 2009
Location: Canada
Online Status: Offline
Posts: 4
Quote iselsrock36 Replybullet Posted: 23 Oct 2009 at 5:15am
Thanks I will try that!!
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.047 seconds.