cancel
Showing results for 
Search instead for 
Did you mean: 

Date Variables, compares to NULL and reinitialize

Former Member
0 Kudos

Hi,

I have the following formula on a detail line:

shared DateVar   PO_Delivery_Date;

shared StringVar PO_Vendor_Name;

shared NumberVar PO_Qty;

if   {Inventory_Stock_Report.PO_Delivery_Date} > PO_Delivery_Date

then ( PO_Delivery_Date := {Inventory_Stock_Report.PO_Delivery_Date};

       PO_Vendor_Name   := {Inventory_Stock_Report.PO_Vendor_Name};

       PO_Qty           := {Inventory_Stock_Report.PO_Qty}; );

Works fine when I display in the Group Footer, using formulas for PO_Delivery_Date, PO_Vendor_Name, and PO_Qty.

Problem is, I need the earliest PO_Delivery_Date, not the latest.

Default value for PO_Delivery_Date is NULL, and there are lots of 'em.  If I switch to "<", I just get blank fields for all three display formulas.

I've tried playing with combinations of NOT ISNULL, and comparing to DATE(1900-0101), but can't seem to find the right combination.

Along with this, I also need to know the syntax to reinitialize the DateVar for the RESET formula.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, Thank you,

No, I'm not displaying Details, and I don't believe the sort within the section matters.  I can play with it, if you have a solution.

But I really would like to know what's tripping up the comparison logic and what I should initialize DateVar to.

abhilash_kumar
Active Contributor
0 Kudos

Hi Matt,

Try this please:

1) Create a formula with this code:

If IsNull({Date field}) OR {Date field} = cdate(0,0,0) then

date(2090,01,01) else

{Date field}


While in the formula editor, look for the drop down on the top that reads 'Exceptions for Nulls', change that to make sure 'Default Values for Nulls'

2) Go to the Record Sort Expert and insert a 'Descending' sort on this formula field.

3) Place the three fields - PO Delivery Date, PO Vendor Name and PO Qty on the Group Footer.

This should always display the 'earliest' PO related data.

Regarding your question about how to reset/initialize a datevar - you'd need to use something like this:

shared DateVar   PO_Delivery_Date := date(0,0,0);


-Abhilash

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Matt,

Do you need to display the details section?

If you do, does the sort order matter?

There's an easy workaround, however, it depends on the answers above.

-Abhilash

Former Member
0 Kudos

Hi, Thank you,

No, I'm not displaying Details, and I don't believe the sort within the section matters.  I can play with it, if you have a solution.

But I really would like to know what's tripping up the comparison logic and what I should initialize DateVar to.