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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need DateTimeVar initialization to zero help

Status
Not open for further replies.

rorymo

Technical User
Nov 7, 2003
75
US
Hi,
Crystal Reports XI (BOXI)
Sql Server 2000

I am creating a formula to handle Daylight Savings Time changes.
To that end, I have created a DateTime range array that contains the datetime start and datetime end of each year's daylight savings time.
This is what it looks like:

Shared DateTimeVar Range Array CHANGE_ORDER_DST :=
[DateTimeValue (2001,04,01,02,00,00) to DateTimeValue (2001,10,28,02,00,00),
DateTimeValue (2002,04,07,02,00,00) to DateTimeValue (2002,10,27,02,00,00),
DateTimeValue (2003,04,06,02,00,00) to DateTimeValue (2003,10,26,02,00,00),
DateTimeValue (2004,04,04,02,00,00) to DateTimeValue (2004,10,31,02,00,00),
DateTimeValue (2005,04,03,02,00,00) to DateTimeValue (2005,10,30,02,00,00),
DateTimeValue (2006,04,02,02,00,00) to DateTimeValue (2006,10,29,02,00,00)];

Next I check the date fields in the report to see if they are in the date range...

If ({@Change Order Open} in CHANGE_ORDER_DST then do this
else
If ({@Change Order Close} in CHANGE_ORDER_DST then
do that

I noticed that the formula gives the correct date on the first field checked, but each field after that keeps the value of the first one. I saw in another thread that you should initialize the variable to zero and put it in the group heading.

I created a formula:
whileprintingrecords;
Shared DateTimeVar Range Array CHANGE_ORDER_DST := ;

But when I check it, it tells me that I need to use a date time array after the :=
I have tried (0000,00,00,00,00,00), 0, Null, "" etc. and
cannot get the checker (x+2) to accept it.

Does anyone know the correct syntax for this?
Thank you very much,
Rory
 
There's nothing to reset that we can see.

If the formula is setting variables as a result of the check (right side of the THENs in the IFs) then you need to reset those.

So post the following:

Section the formula is in
The actual formula!
If you are displaying results of this formula in a subsequent section, and where

-k
 
Try:

whileprintingrecords;
Shared DateTimeVar Range Array CHANGE_ORDER_DST := [datetime(0,0,0,0,0,0) to datetime(0,0,0,0,0,0)];
0 //add the 0 because you can't end a formula with an array

-LB
 
SV: Oh, yeah, I wasn't thinking.

rorymo--

Please ignore my last post. I think the issue might be that{@Change Order Open} and {@Change order Close} share the same rows, so that if the Open field meets the criteria, the Close field doesn't get evaluated. Break your formula into two and include only one clause in each:

If ({@Change Order Open} in CHANGE_ORDER_DST then do this;

Or you could combine this into one formula using ";" instead of "else" where the two clauses are referenced elsewhere in two separate formulas.

-LB
 
Thank you both so much for your great responses.
I am going to try all right now.
thanks again,
Rory


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top