Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date Range based on print date Post Reply Post New Topic
Author Message
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Topic: Date Range based on print date
     Posted: 31 Aug 2009 at 8:07am
What would be the formula for a date range that references the most recent 7am-7am period from the print date?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Aug 2009 at 9:09am
Try:
{table.datetimefield} in (date(dateadd("d",-1,today)) + time(07,00,00)) to (today + time(07,00,00))
IP IP Logged
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Posted: 31 Aug 2009 at 9:16am
Thanks very much DBlank!
If the report is run before 7 am I would like it to call the 7 am to 7 am period from the day prior. I think the approach would be to add an if/then that if the report is run before 7 am then the range would be dateadd -2 plus 7 hoursa to dateadd -1 plus 7 hours. Does that sound correct?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Aug 2009 at 9:23am
Yep. I think this is what you want:
if currenttime in time(00,00,01) to Time(07,00,00) then
{table.datetimefield} in (date(dateadd("d",-2,today)) + time(07,00,00)) to (date(dateadd("d",-1,today))  + time(07,00,00))
else
{table.datetimefield} in (date(dateadd("d",-1,today)) + time(07,00,00)) to (today + time(07,00,00))
 


Edited by DBlank - 31 Aug 2009 at 9:24am
IP IP Logged
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Posted: 31 Aug 2009 at 10:06am
Thanks that is it. But I am having a problem that I get an error message when trying to save formula that "the ) is missing" after the first comma in (07,00,00). What would cause that?
IP IP Logged
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Posted: 31 Aug 2009 at 10:11am
caught my mistake... forgot to add the time function before the (07,00,00)!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 Aug 2009 at 10:12am
Thumbs%20Up
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