Assume a table with date data stored as numbers defined as 8,0.
    NBRDTE
20,140,228
20,140,229
20,140,430
20,140,431
20,140,304
In a 6.1 or newer box, you can use "timestamp_format" to convert these numbers into dates, if they are valid dates.
Running this SQL will convert those numbers that can be translated into dates and fail to convert the others.
SELECT nbrdte,
timestamp_format(digits(nbrdte),'YYYYMMDD')
FROM fakedates
    NBRDTE   TIMESTAMP_FORMAT
20,140,228   2014-02-28-00.00.00.000000
20,140,229   ++++++++++++++++++++++++++
20,140,430   2014-04-30-00.00.00.000000
20,140,431   ++++++++++++++++++++++++++
20,140,304   2014-03-04-00.00.00.000000
So you could use this to test the numbers entered as representing dates or to identify those numbers that are not correct representations of dates.
Steve Needles
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Hoteltravelfundotcom
Sent: Tuesday, May 06, 2014 10:26 AM
To: Midrange Systems Technical Discussion
Subject: can this reject bad data?
There is some bad data in our system. there is a lack of
validate checking. in this case, can this sql reject for processing
any such bad dates? bad dates are defined as month > 12 and days accordinlgy
SELECT
  ALL       T01.UAUSRN,
            SUBSTR(DIGITS(UAFLWD),5,2) CONCAT '/' CONCAT
SUBSTR(DIGITS(UAFLWD)
            ,7,2) CONCAT '/' CONCAT SUBSTR(DIGITS(UAFLWD),3,2) AS FOLLOWUP,
            (T01.UAENT#), T01.UASFX#, T02.ADENTN, T01.UANOTT, T01.UANOTL,  T02.ADLNM, T02.ADFNM,
            T01.UAFLWD
  FROM      ASTDTA.NOTEHDUA T01 INNER JOIN
            ASTDTA.ADRESsad T02
  ON        UAENT# = ADENT#
    AND     UASFX# = ADSFX#
  WHERE     UAFLWD BETWEEN 20000101 AND 20991231
    AND     UAPRGD < 1
    AND     UANOTT = 'E'
  ORDER BY  001 ASC, 008 ASC
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: 
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at 
http://archive.midrange.com/midrange-l.
________________________________
This communication, including attachments, is confidential, may be subject to legal privileges, and is intended for the sole use of the addressee. Any use, duplication, disclosure or dissemination of this communication, other than by the addressee, is prohibited. If you have received this communication in error, please notify the sender immediately and delete or destroy this communication and all copies.
TRVDiscDefault::1201
As an Amazon Associate we earn from qualifying purchases.