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!

Replacing a null date field with another date in a formula 1

Status
Not open for further replies.

bcmom90

IS-IT--Management
Mar 15, 2006
5
I am using Crystal Reports 9. I have similar fields from 2 different tables.I want to replace any null Dates from the Purc_Order_Line table with the ones from the Purchase_Order table. Here's what I tried:

if DateValue ({PURC_ORDER_LINE.DESIRED_RECV_DATE})= DateValue (0,0,0 ) then
DateValue ({PURC_ORDER_LINE.DESIRED_RECV_DATE}) else
DateValue ({PURCHASE_ORDER.DESIRED_RECV_DATE})

I've tried every sort of Date function and nothing is happening. Has anyone been successful doing this and, if so, how is it done?
 
Why are you using datevalue? What are the datatypes of your two fields?

-LB
 
As I previously stated, I've tried several Date functions. These fields are definitely date-time fields. How would you write this formula? I would appreciate any assistance.
 
Try:

if isnull({PURC_ORDER_LINE.DESIRED_RECV_DATE})
or
{PURC_ORDER_LINE.DESIRED_RECV_DATE} < cdate(1970,1,1)
then
DateValue ({PURC_ORDER_LINE.DESIRED_RECV_DATE})
else
DateValue ({PURCHASE_ORDER.DESIRED_RECV_DATE})

Thsi takes the approach of the field being either null, or before some date that would never appear in the field (adjust 1/1/1970 accordingly).

Many date fields are NEVER blank or 0/0/0, it depends on the database type, so remember that if you post about data, include the database type and connectivity used.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top