Hi All,
I would like to know if there is any function available in DataStage such that
It Returns TRUE or FALSE to indicate whether a string represents a valid date in the specified format.
I have looked at the options but didn't find one. Just want to know if I missed it by any chance.
Thanks
Kris
Valid Date function
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
I think it is 'DateGenericIsDate' transform to check for the validity of a date. But it checks only a certain number of formats.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Not really out of the box. The SDK routine is very specific about format. The function, however, is very easy, provided you specify the format in a manner expected by Iconv() - that is, "DDMY", "DMDY" or "DYMD".
Code: Select all
FUNCTION IsValidDate(TheDate, Format)
If UnAssigned(Format) Or IsNull(Format) Or UnAssigned(TheDate) Or IsNull(TheDate)
Then
Ans = @NULL
End
Else
Test = Iconv(TheDate, Format)
Ans = Not(Status())
End
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Validate Date Function
In my project I needed a routine to check whether a date is in valid format. We need to give the input format which has been specified as CCYYMMDD. I am describing the functionality and the code below. Please suggest any improvement that can be incorporated
Arguments:
Arg1 = aINDATE : Input date
Arg2 = Format of input date : aVALIDFORMAT
Called by:
Transformer
Routine Functionality:
The routine check whether the input date is in valid format.
Return Values:
0 = If the Input Date is in Valid format
1 = If the Input Date is NOT in Valid format
Arguments:
Arg1 = aINDATE : Input date
Arg2 = Format of input date : aVALIDFORMAT
Called by:
Transformer
Routine Functionality:
The routine check whether the input date is in valid format.
Return Values:
0 = If the Input Date is in Valid format
1 = If the Input Date is NOT in Valid format
Code: Select all
************************************************************************
* Input Argument: Input : Input Date *
* Sformat : The Valid Date Format CCYYMMDD *
*************************************************************************
Input = aINDATE
Sformat = Upcase(aVALIDFORMAT)
Output=1
If Sformat = "CCYYMMDD" Then
Convert=Iconv(Input,"D-YMD[4,2,2]")
End
ConvStatus= Status()
*************************************************************************
* Output: 1 if there is error or warning in conversion *
* 0 if the conversion is successful *
*************************************************************************
Begin Case
Case (ConvStatus=1 or ConvStatus=2 or ConvStatus=3)
Output=1
Case ConvStatus=0
Output=0
End Case
Ans= Output
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.