[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] validating date from yyyymodd input



Here's some code I just checked out to see if it would work (my RDBMS is
DB2).

In the example below, it detected that the date was invalid and went to the
bad-date procedure.  On a good date, the program completed successfully.

You might want more sophistication in the bad-date procedure or to use a
different table in the select, but I don't think you should use any table
other than one you know will only have one row.

begin-program

let $d = '2003-14-31'

begin-select on-error=bad-date
'x'
from dbadb2tm.psstatus
where date(lastrefreshdttm) = $d
end-select

end-program


begin-procedure bad-date

    show 'date ' $d ' is invalid'
    
end-procedure

-----Original Message-----
From: the dragon [mailto:ceprn@hotmail.com]
Sent: Thursday, July 17, 2003 6:57 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] validating date from yyyymodd input


Hi all.

I am searching the database as we speak, but there are 281 matches to week 
through with my search criteria, so I'll ask here also. Maybe save some 
time.  I am having users enter a date as YYYYMODD into a flat file and then 
checking to make certain what they have entered is a valid date in the sqr 
before I continue processing.  If the date entered is invalid, I am going to

write an error message and continue processing the remaining records - I 
don't want the entire sqr to blow up if the users act as users.

I know I can check to make sure the field in numeric, but then how can I 
check to see if the date is valid?  I am trying to leverage datetime.sqc, 
and use begin-procedure Get-DateComponents 
($indate,:#wkYears,:#wkMonths,:#wkDays) but I am not sure this will really 
do what I want - any ideas?

I haven't been using sqr as much as I would have liked over the past 18 
months and I am rustier than I should be, so pardon the questions.  Boy does

it feel good to use it again though!!!

clark

PSA: Salary <> Slavery.  If you earn a salary, your employer is renting your

services for 40 hours a week, not purchasing your soul.  Your time is the 
only real finite asset that you have, and once used it can never be 
recovered, so don't waste it by giving it away.

"Time is the coin of your life. It is the only coin you have, and only you 
can determine how it will be spent.  Be careful lest you let other people 
spend it for you."

Carl Sandburg
(1878 - 1967)

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users