Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Issue: Empty dates and computation
Message
From
02/01/2005 05:19:31
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Issue: Empty dates and computation
Miscellaneous
Thread ID:
00973689
Message ID:
00973689
Views:
52
I want a new set on VFP10
SET SETUNKNOWNRESULTTONULL OFF | ON
Empty concept it is an obsolete concept that arrives from the origins of XBase.
VFPT has the courage to abandon it?

A example:
CLEAR
d1 = DATE()
d2 =DATE(2005,2,31) && return a empty date because the date don't exists
? d1#d2,d1-d2 && are not equal, but difference is zero !! ( empty date go to a empty number )
* workaround, map empty to NULL
d2 =EVL(DATE(2005,2,31),CAST(NULL AS D))
? d1#d2,d1-d2

* effect of empty on computation
dRef = {^2005/1/1}
CREATE CURSOR TESTDATE (DD D NULL)
INSERT INTO TESTDATE VALUES (DATE(2005,2,31)) && this is a unknown date
INSERT INTO TESTDATE VALUES (dRef+1)

SELECT AVG(DD-m.dRef) AvgDiff FROM TESTDATE && Average it is mistaken
USE
ZAP IN TESTDATE
* WORKAROUND
INSERT INTO TESTDATE VALUES (EVL(DATE(2005,2,31),NULL))
INSERT INTO TESTDATE VALUES (dRef+1)

SELECT AVG(DD-m.dRef) AvgDiff FROM TESTDATE
Fabio
Next
Reply
Map
View

Click here to load this message in the networking platform