Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: numeric date problems Post Reply Post New Topic
Author Message
apluvr
Newbie
Newbie


Joined: 15 Oct 2014
Online Status: Offline
Posts: 5
Quote apluvr Replybullet Topic: numeric date problems
    Posted: 16 Dec 2014 at 5:57am
I'm writing a report that will run on Monday of every week.  It is meant to capture data from the past business week.  The problem is that in this particular table, the date is in numeric format MMddyy.  So here is my Select formula:
 
local numbervar TodaysDate := tonumber(totext(currentdate,'MMddyy'));
local numbervar LWDay1 := TodaysDate - 700;
local numbervar LWDay2 := TodaysDate - 600;
local numbervar LWDay3 := TodaysDate - 500;
local numbervar LWDay4 := TodaysDate - 400;
local numbervar LWDay5 := TodaysDate - 300;
{XFER.XfrDate} in [LWDay1, LWDay2, LWDay3, LWDay4, LWDay5]
 
Unfortunately this runs for an inordinate length of time.  I've never actually had the patience to see if it completes, and end up using task manager to shut down crystal reports after 10 minutes or so.
 
Any thoughts on why this happens, or how to do this better?
 
Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Dec 2014 at 6:13am
are you sure your field is numeric? I thnk it neerds to be a string to maintain the MMddyy format you mention.
 
date(picture({XFER.XfrDate},'xx/xx/20xx')) in lastfullweek
and
weekday(date(picture({XFER.XfrDate},'xx/xx/20xx'))) in 2 to 6
IP IP Logged
apluvr
Newbie
Newbie


Joined: 15 Oct 2014
Online Status: Offline
Posts: 5
Quote apluvr Replybullet Posted: 16 Dec 2014 at 6:23am
thanks for the response.  I just checked, definitely numeric.  So today's date (12/16/2014) would be 121614.  January 1st 2015 would be 10115.
IP IP Logged
apluvr
Newbie
Newbie


Joined: 15 Oct 2014
Online Status: Offline
Posts: 5
Quote apluvr Replybullet Posted: 16 Dec 2014 at 6:26am
...and just realized my algorithm won't work if a week straddles two months.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Dec 2014 at 6:30am
date(picture(totext({XFER.XfrDate},'000000',0,''),'xx/xx/20xx')) in lastfullweek
and
date(picture(totext({XFER.XfrDate},'000000',0,''),'xx/xx/20xx')) in 2 to 6
 


Edited by DBlank - 16 Dec 2014 at 6:30am
IP IP Logged
apluvr
Newbie
Newbie


Joined: 15 Oct 2014
Online Status: Offline
Posts: 5
Quote apluvr Replybullet Posted: 16 Dec 2014 at 6:48am
thanks DBlank!  I have a working report now.  I didn't quite understand your response, but I adapted it to my own use.  Here is my selection formula:
 
if {XFER.XfrDate}<>0 then
  date(picture(totext({XFER.XfrDate},'000000',0,''),'xx/xx/20xx')) in today()-7 to today()-3
 
this runs relatively quickly.  (Less than a minute.)  Thanks for the prompt replies!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 Dec 2014 at 7:26am
your code will only work on a monday
the one I gave you gives 2 criteria.
it has to be in the last full week and the weekday has to be a M-F.
This give you the option of running it any day during the week to get the prior weeks data.
I try not to use if-then statements in a select
try and change it to an "and"
 
{XFER.XfrDate}<>0 and
 date(picture(totext({XFER.XfrDate}...
 
IP IP Logged
apluvr
Newbie
Newbie


Joined: 15 Oct 2014
Online Status: Offline
Posts: 5
Quote apluvr Replybullet Posted: 16 Dec 2014 at 7:28am
oh i see.  thanks for the tips!
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.031 seconds.