Year in Date validation

davidvilla

Member
Is there any inbuilt validation available to validate the year field in a date?

I have a txt file, from which I will get get the dates and convert them to DATE types. If my year has any spl chars in it, DATE typecasting is not working.
DEF VAR mychar AS CHAR NO-UNDO.
ASSIGN mychar = "12/12/hfjf".
DISPLAY DATE(mychar).

Result - 12/12/10.

Is there any inbuilt validations available to validate the date as such. else, I have to use ASCII codes to check them.

Thanks in advance!
 
def var dateyear as integer.
def var importstring as character.

importsrting = "12/12/hfjf"
dateyear = INTEGER(substring(importstring,7)) NO-ERROR.
if error:error-status = true then
message "invalid year".
else
resultdate = DATE (integer(substring(importstring,1,2)), integer(substring(importstring(4,2)), dateyear).
 
I do month/day/year validation the same way
datemonth = integer (substring(is,1,2)) NO-ERROR.
dateday = integer (substring (is,4,2)) NO-ERROR.
 

davidvilla

Member
When you convert "qq/12/2010" or "12/qq/2010" to DATE, they throw the "Invalid Date Input" error. But when I convert "12/12/10qq", Progress accepts it. Is there any reason behind it?
 

davidvilla

Member
DEF VAR mychar AS CHAR NO-UNDO.
ASSIGN mychar = "12/1v2/9999".
DISPLAY DATE(mychar) FORMAT "99/99/9999".

result - 12/12/2010
 
It is getting accepted at what level, where in the process.
Progress should not allow a character in a date field, at UI level.
It must be entered on-the-fly somewhere. Which again the database definition should not allow a char.
Sorry.
 

davidvilla

Member
DEF VAR mychar AS CHAR NO-UNDO.
ASSIGN mychar = "12/1v2/9999".
DISPLAY DATE(mychar) FORMAT "99/99/9999".
This is my code as such. Shouldn't throw an error?
When I run this in my Procedure editor, i got the result "12/01/2010".

Please See the attachment for more details.

Thanks.
 

Attachments

  • dateerror..doc
    58.5 KB · Views: 12
Greetings,

Just how dumb are you and that is not a rhetorical question. Progress is performing exactly as you instructed it,
You have told the compiler mychar = "12/1v2/9999".
Then you run this in Procedure editor, telling the compiler to display a string with a date format for the result "12/12/2010". Progress is doing what you have instructed it to do??
BFN
 
Progress is allowing you to store a string as a variable.

Progress is then allowing you to display a string, as close to a date as possible.
Even though the string is not a date.

The problem is with VALIDATION, the entered string should NOT be allowed to be entered.
That is why it is falling down. Not because there is a problem with Progress.
Progress is only following instructions.
 

davidvilla

Member
Thanks for your efforts!
I understand what is happening. I was just looking for any inbuilt functions to validate the date. Can you help now?
 
Greetings,

There is not inbuilt function available, it is called validation.
At data entry level, you require a validation routine. You have to pay programmers to do the work.
Progress is this massively efficient 4GL/ABL, though it cant do all the work for you.
 
Top