Solved

How do I reset Global DateTimeVar to Null (Empty/Blank)?

Posted on 2004-09-21
6
1,071 Views
Last Modified: 2008-01-16
Quick question --

How do I reset a global DateTime variable to null/empty/blank? If it's a number, that's easy. But what about if it's a datetime variable?

For instance, I have the following formula (DisplayInst) which evaluates at a group footer:

WhilePrintingRecords; Global DatetimeVar InstVar

This displays the Datetime variable "InstVar" which is created earlier in the details section with the following formula (CalcInst):

WhilePrintingRecords;
If InStr({_Custom__rptUpgradedClients_1.Name},{?NewVersion}) > 0 then
Global DateTimeVar InstVar := {_Custom__rptUpgradedClients_1.InstallDate}

The variable compares a product name field with a version parameter field. If successful, it updates the InstVar variable with an install date. This works fine until it reaches a record that has a null _Custom_rptUpgradedClients_1.InstallDate from the SQL table. When this occurs, the Global InstVar is still the same as the previous record, so it prints the previous record's Install Date.

I was thinking something like:

WhilePrintingRecords;
If InStr({_Custom__rptUpgradedClients_1.Name},{?NewVersion}) > 0 then
Global DateTimeVar InstVar := {_Custom__rptUpgradedClients_1.InstallDate}
else
Global DateTimeVar InstVar := NULL, Empty, Blank, 0, etc...

but I'm not sure of the syntax on how to empty the variable.

I'm actually pretty sure the above solution would bring problems. I was thinking I needed to reset the variable each time the group is passed. But again, I need to know how to empty the variable.

I'm a newbile when it comes to this, so any help would be greatly appreciated :) Thanks!
0
Comment
Question by:eledol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
bdreed35 earned 250 total points
ID: 12114989
You are better off creating a out of range date instead of trying to set it to NULL:

WhilePrintingRecords;
If Isnull(({_Custom__rptUpgradedClients_1.Name})  or InStr({_Custom__rptUpgradedClients_1.Name},{?NewVersion}) = 0 then
    Global DateTimeVar InstVar := cdate(1800,1,1)
else
    Global DateTimeVar InstVar := {_Custom__rptUpgradedClients_1.InstallDate}

You can then test for the out of range date value in another formula, or suppress the field when it equals cdate(1800,1,1).
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 250 total points
ID: 12115555
Date (0, 0, 0) is the "null" date value so to set a date to null you can use: cdate(0,0,0)

You can find this and other types by searching help for "default values for the simple types"

frodoman
0
 
LVL 28

Expert Comment

by:bdreed35
ID: 12115672
Good point frodoman.

Using the NULL date value, you can alter the formula I gave you to this:

WhilePrintingRecords;
If Isnull(({_Custom__rptUpgradedClients_1.Name})  or InStr({_Custom__rptUpgradedClients_1.Name},{?NewVersion}) = 0 then
    Global DateTimeVar InstVar := cdate(0,0,0)
else
    Global DateTimeVar InstVar := {_Custom__rptUpgradedClients_1.InstallDate}

This works well if you are using this to display.  You won't need to suppress the field because cdate(0,0,0) will display as a blank field.

One thing to note, I tried using the IsNull() function on a formula that had the value cdate(0,0,0), and the result was false.  I was expecting a true value since the help files say that it is the NULL date value.
So, even if you set it to a null date, you will still need to test for cdate(0,0,0) since Crystal doesn't seem to look at it as NULL, except for display purposes.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 12115781
I agree w/ everything Brian said.  

Testing for 0,0,0 probably makes the code more understandable and there's no chance of an actual date conflicting -- hopefully that's not an issue with Jan 1800 either though :-)
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question