Troubleshooting
Problem
Using the IsValid function to check for a valid date. However, the function throws a warning if there is an actual bad date. In DataStage v7 and v8.1, there is no warning but in v8.5 and above, a warning appears. Some examples: Scenario 1: StageVar=20141231 If IsValidDate( "2014-12-31" ) Then "Valid" Else "InValid" Returns= Valid No Log Warnings Scenario 2: StageVar=20143112 If IsValidDate(" 2014-31-12" ) Then "Valid" Else "InValid" Returns= InValid Log Warnings= Conversion error calling conversion routine date_from_ustring data may have been lost Scenario 3: StageVar=20143112 If IsValidDate(StringToDate( "2014-31-12" ,"%yyyy-%mm-%dd")) Then "Valid" Else "InValid" Returns= InValid Log Warnings= APT_CombinedOperatorController,1: Conversion error calling conversion routine date_from_string data may have been lost
Cause
A warning message will occur with the use of IsValidDate or IsValid("date",StringToDate(string,"%mm/%dd/%yyyy") ) because it is trying to convert the invalid string value to date before it actually checks to see if it is valid.
Resolving The Problem
To resolve this issue, use the function:
IsValid ("date", String1[1,4]:"-":String1[5,2]:"-":String1[7,2])
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21672650