Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help adding DateTime field

Status
Not open for further replies.

MerlinTheWizard

Technical User
Mar 26, 2004
5
US
Version:Crystal 8.5 and 9
Datasource: Access 2000

The problem I am having is getting Crystal to add a constant value to a DateTime field. My first attempts have been using the following:

DateAdd ("D", {FM_SCHEDULE.FREQUENCY_NR}, {FM_SCHEDULE.TRIGGER_DT})

What I'm looking for is it to repeat this process and display each result. If the field reads 3/1/2004 12:00:00 PM then Im looking to show:
3/8/2004 12:00:00 PM
3/15/2004 12:00:00 PM..etc...
with the FREQUNCY_NR being 7.

I will also need to do this for various numbers of months, weeks, and years. Any help would be appreciated. Thank you in advance.
 
Are you requesting that Crystal fabricate dates given a starting date of some point?

How many dates would it create?

Try posting example data and demonstrate what is going to be output with a reasonable explanation of why it would do so.

Crystal is NOT a database program, so it doesn't create rows. You can create addional dates to output using something like:

whileprintingrecords;
datevar array MyDates;
numbervar DateCount:=1;
numbervar X := 4;
//replace 4 with the amount of weeks to display
datevar MyDate := currentdate;
redim MyDates[X];
For DateCount := 1 to X do(
MyDates[DateCount] := currentdate+(7*DateCount)
);
MyDates[1]

Note that in the end I am outputting only the first date of the array using a subscript identifier[1].

If this isn't what you seek, please provide more information.

-k
 
The table I'm using is used to determine when the program is going to create a workorder. I've been asked to create a report to forecast what will be created but the database doesn't give me much to work with. There will be a date range parameter on the report that will cover anything from a week up to atleast a full year. My main fields I have to work with are:
FM_SCHEDULE.TRIGGER_DT = (1/1/2004 12:00:00) my starting date
FM_SCHEDULE.FREQUENCY_TYPE_CD = (M)month, (D)day, (W)week
FM_SCHEDULE.FREQUENCY_NR = (7) # field used with above to determine every 6 months, 7 days, etc

Using the trigger_dt above and my database fields read:
FREQUENCY_CD FREQUENCY_NR
D 7
M 1
Then I'm looking for the report to show
January 2004 (Group Header)
1/1/2004 12:00:00
1/8/2004 12:00:00
1/15/2004 12:00:00
1/22/2004 12:00:00
1/29/2004 12:00:00
February 2004 (Group Header)
2/1/2004 12:00:00
2/5/2004 12:00:00
etc...

I have fudged it using the following formulas:
Formula:mad:Daily
If {FM_SCHEDULE.FREQ_TYPE_CD} = "D" then DateAdd("D", {FM_SCHEDULE.FREQUENCY_NR}, {FM_SCHEDULE.TRIGGER_DT})
this gives me 1/8/2004 12:00:00
Formula:mad:Daily1
if {FM_SCHEDULE.FREQ_TYPE_CD} = "D" then DateAdd("D", {FM_SCHEDULE.FREQUENCY_NR}, {@Daily})
this gives me 1/15/2004 12:00:00
I would need an infinate number of formulas to get anywhere.
Are they asking too much of Crystal with the little data I am given?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top