Date Validation Using SQR

Your rating: None Average: 3.5 (2 votes)

Here is some SQR to help you validate a date format. You can modify the code to fit your own needs and date format you desire.

!-------------------------------------!
! Procedure: Date-Validation !
! Descr: Validate $entered_date. !
!-------------------------------------!
Begin-Procedure Date-Validation
#debug show 'Entering Date-Validation'
Let $Date_Validation = 'N'
!Show '$entered_date: ' $entered_date
Let #1st_Slash_position = instr($entered_date, '/', 1)
!Show '#1st_Slash_position: ' #1st_Slash_position
Let #2nd_Slash_position = instr($entered_date, '/', #1st_Slash_position + 1)
!Show '#2nd_Slash_position: ' #2nd_Slash_position
If ((#1st_Slash_position > 0 AND #2nd_Slash_position > 0
AND length($entered_date) >=8) Or isblank($entered_date))
Move 'Y' To $Date_Validation
Else
Add 1 to #Recs_Rej
Show 'Record number ' #Tot_Recs ' has an invalid date format. Record will NOT be uploaded.'
Show 'Invalid Date: ' $entered_date
Show ' '
Print 'Record number ' (+2,1)
Print #Tot_Recs () edit 8888888888
Print ' has an invalid date formate. Record will NOT be uploaded.' ()
Print 'Invalid Date: ' (+1,1)
Print $entered_date ()
End-If
End-Procedure Date-Validation

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!