Page 1 of 1

Date Cleansing

Posted: Mon Oct 24, 2005 7:59 am
by gsherry1
Is there some reason for the inconsistency in the way DS handles invalid dates?

For Example, a day value that exceeds the normal range for that month returns null, but if it happens to be February 29th in a non-leap year, it returns the first of the next month.

This means there is no way to capture invalid dates by looking for null output. Is there a way to get around this?

Thanks.

Posted: Mon Oct 24, 2005 8:02 am
by chulett
Returns null from what? How are you doing your date handling / checking? Read the online help for the Status() function, it comes in very handy for date handling inside a routine and the example there is specific to date validation, from what I recall.

Posted: Mon Oct 24, 2005 8:13 am
by kcbland
The trick is to ICONV a date, then OCONV the date and verify that the same month comes back.

For fun, try 2-28, 2-29, 2-30, and 2-31. See what happens. Fun with dates!!! 8)

Posted: Mon Oct 24, 2005 8:29 am
by ArndW
Gsherry1,

The OCONV/ICONV functions all return a status code. When a date could be correct and a rule can be followed, the conversion is done and a warning STATUS is returned {which is of course ignored in derivations}; while an invalid date isn't converted and an error STATUS is set {once again, unused and ignored in mere derivations?}.

In order to change this behaviour you need to put the conversion into a routine and handle the potential warnings and errors yourself.

So the date conversions are not really inconsistent, we just don't normally use the full functionality.

Posted: Mon Oct 24, 2005 9:31 am
by gsherry1
Thanks. The status function came in handy here. I needed to distinguish status=1 and status=3.