Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Calculating a date Post Reply Post New Topic
Author Message
bremen
Groupie
Groupie
Avatar

Joined: 28 May 2013
Online Status: Offline
Posts: 93
Quote bremen Replybullet Topic: Calculating a date
     Posted: 05 Jul 2013 at 1:25am
I am trying to calculate a date.  The clock should start ticking based on {table1.field1} I would like it to display the number of days from {table1.field1} until the curent date until {table2.field2} is no longer null.  Once {table2.field2} is no longer null I would like to have the the number of days between {table1.field1} and {table2.field2}. 
IP IP Logged
praveeng
Senior Member
Senior Member
Avatar

Joined: 11 Jul 2011
Online Status: Offline
Posts: 165
Quote praveeng Replybullet Posted: 05 Jul 2013 at 2:36am

Numbervar d;


if IsNull({table2.field2}) or ({table2.field2} = "") then
 d:= {table1.field1} - CurrentDate
else
 d:= {table1.field1} - {table2.field2};


numbervar b := a mod 365;
numbervar c := b mod 30;

ToText(Truncate(d/365),0) +" yr(s) "+ ToText(Truncate(b/30),0) +" mth(s) "+ ToText(c,0) +" day(s)";

Praveen Guntuka,
praveen_guntuka@yahoo.com
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Jul 2013 at 3:37am
or
datediff('d',table1.field,if isnull(table2.field) then currentdate else table2.field)
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