Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: is DateTime in next 24hrs? Post Reply Post New Topic
Author Message
roxaneamanda
Newbie
Newbie


Joined: 10 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote roxaneamanda Replybullet Topic: is DateTime in next 24hrs?
     Posted: 13 Aug 2009 at 1:32am

How do I create a formula which will tell me if a datetime field falls into the next 24 hours at time of running the report or if it falls within the last 24hours?

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Aug 2009 at 6:17am
use dateadd and/or datediff depending on how you want to compare, you can use them alone or together.
 
if datediff(h,now,{table.field}) < 24 then
or
if {table.field} in now to dateadd(h,24,now) then
 
there are more, just depends on what you want.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Aug 2009 at 7:10am

given your other post for conditional couting you can use these formulas in the Running Total. If they evaluate to True the record is included in the count.

for in last 24 hours using minutes as you base:
datediff("n",{table.datetimefield},currentdatetime) in 0 to 1440
 
for in the next 24 hours using minutes as you base:
datediff("n",currentdatetime,{table.datetimefield}) in 0 to 1440
IP IP Logged
roxaneamanda
Newbie
Newbie


Joined: 10 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote roxaneamanda Replybullet Posted: 19 Aug 2009 at 4:05am
Thanks, I have used the following then added in a group summary to count and this has worked perfectly. Thanks
 
if datediff("n",{ITSM_WORKORDERS.WOR_DEADLINE},currentdatetime) in 0 to 1440 then'Last24'
else if datediff("n",currentdatetime, {ITSM_WORKORDERS.WOR_DEADLINE}) in 0 to 1440 then'Next24'
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