IsValid with date format

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
philos15
Participant
Posts: 13
Joined: Fri Apr 21, 2006 8:24 am

IsValid with date format

Post by philos15 »

I have a prblem with the function IsValid :

IsValid("date [%yyyy%mm%dd]", Ln_pour_controle.date_creation)

tell me this error :

APT_CombinedOperatorController,0: The schema type "date" does not take parameters "%yyyy%mm%dd"

could you tell me where is the syntax error

thank's a lot
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Basically it is telling you that IsValid("date", Ln_pour_controle.date_creation) is legal but IsValid("date [%yyyy%mm%dd]", Ln_pour_controle.date_creation) is not.

That is, in the IsValid() function, the first argument must be a literal string that does not contain a formatting parameter.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
philos15
Participant
Posts: 13
Joined: Fri Apr 21, 2006 8:24 am

Isvalid

Post by philos15 »

ray.wurlod wrote:Basically it is telling you that IsValid("date", Ln_pour_controle.date_creation) is legal but IsValid("date [%yyyy%mm%dd]", Ln_pour_controle.date_creation) is n ...
thank's for your answer,

When you go in the help manual, it's clearly written that you can put a format just after,..

when I use just IsValid("date",...) it's working, but if I put a caracter just after date for exemple : IsValid("dateAAAAA",...) it says " [ expected".

If I put IsValid("date [.....]",...), it says " date does not take parameters ... "

I know that in a modify I have to write toto:string = ["%yyyy%mm%dd"]string_from_date(my_date)
with " , but in my string, how to use the " ?


Do you have an other way to verify if a string is well AAAAMDD formatd ??

Thank's in advance for your answer
:?
philos15
Participant
Posts: 13
Joined: Fri Apr 21, 2006 8:24 am

Post by philos15 »

IsValid(date "%yyyy-%mm-%dd", ... don't work, it's waiting a string in first parameter,

if I put IsValid("date ["%yyyy%mm%dd"]",...) it's "red" because of the " in the string

In other langages, there's \" or "" to put the " caracter in a string,

If Ascential's engineer have put the fonction, that's that it normally works, no ? :roll:

thank's in advance for your answer,...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can not be 100% certain that what is in the product is accurately documented in the manuals, particularly for components that came from Torrent Systems.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
philos15
Participant
Posts: 13
Joined: Fri Apr 21, 2006 8:24 am

Post by philos15 »

ray.wurlod wrote:You can not be 100% certain that what is in the product is accurately documented in the manuals, particularly for components that came from Torrent Systems. ...
so how do you do to verify a AAAAMMDD date ? with a 1/0 or true/false response ?
bandish
Participant
Posts: 41
Joined: Tue Oct 11, 2005 1:30 am

Post by bandish »

Hi,

May be you can use

IsValid('DATE',StringToDate(<Column Name>,"%yyyy%mm%dd"))

It will give output as 1 or 0 depending on if the date is valid or not for the provided format.

Thanks
Bandish
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I have written a server version of IsValid(). I shall post it in a couple of weeks (when I get back to DataStage work).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mrlindsey
Participant
Posts: 4
Joined: Thu Jan 19, 2006 8:47 am
Location: MA, USA
Contact:

Post by mrlindsey »

I need to do something similar.
Where in the job would you put the IsValid() function so that the job will fail if the function fails?
philos15
Participant
Posts: 13
Joined: Fri Apr 21, 2006 8:24 am

Resolved

Post by philos15 »

bandish wrote:Hi,

May be you can use

IsValid('DATE',StringToDate(<Column Name>,"%yyyy%mm%dd"))

It will give output as 1 or 0 depending on if the date is valid or not for the provided format.

Thanks
Bandish
Thank's a lot, it's working without warning :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Here 'tis

Post by ray.wurlod »

Short Description
-----------------

Reports whether test value complies with the rules for a particular data type


Long Description
----------------

Returns NULL if either argument is not assigned or if the data type argument is null or unknown.
Always returns 1 (true) if the test value argument is null, because null is valid for any data type.
No range checking is performed for Float, Real, Double or DFloat data types; it suffices that these are numeric.
Strings containing more than 38 numeric characterse are not considered to be numeric (see BASIC manual).

Supported data types are:

Code: Select all

   uint8
   int8			tinyint
   uint16
   int16		  smallint
   uint32
   int32		  integer		int
   uint64
   int64		  bigint
   char(n)		string[n]
   varchar(n)	string[max=n]
   decimal(p,n)	numeric(p,n)	number
   float		  real
   dfloat		 double
   date
   time
   timestamp
Date and time data may be in appropriate format for current locale or in ISO 8601 format.

===========================================================================================================

Code: Select all

FUNCTION IsValid(argTestValue, argDataType)

$COPYRIGHT "Copyright (c) 2002-2006, Ray Wurlod.  All rights reserved."
$INCLUDE UNIVERSE.INCLUDE UVNLSLOC.H
$UNDEFINE TESTING

      DEFFUN IsValid(TheTestValue, TheDataType) Calling "DSU.IsValid"

      Equate RoutineName To "IsValid"

      * Constants for range checking integer data types
      Equate MinTinyInt To -2^7, MaxTinyInt To 2^7-1, MaxUInt8 To 2^8-1
      Equate MinSmallInt To -2^15, MaxSmallInt To 2^15-1, MaxUInt16 To 2^16-1
      Equate MinInteger To -2^31, MaxInteger To 2^31-1, MaxUInt32 To 2^32-1
      Equate MinBigInt To -2^63, MaxBigInt To 2^63-1, MaxUInt64 To 2^64-1

      * Pattern that all signed integers must match
      Equate IntgerPattern To "1N0N" : @VM : "'-'1N0N" : @VM : "+'1N0N"

      * Pattern that all timestamps must match: "YYYY-MM-DD HH:MM:SS" or "YYYY-MM-DD HH:MM:SS.s..."
      Equate TimestampPattern To "4N'-'2N'-'2N' '2N':'2N':'2N" : @VM : "4N'-'2N'-'2N' '2N':'2N':'2N'.'1N0N"

      * Decimal place designator (from NUMERIC locale if NLS enabled, otherwise "."
      LInfo = LocaleInfo(UVLC$NUMERIC)
      If LInfo = LCE$NO.LOCALES
      Then
         DecimalPlace = "."
      End
      Else
         DecimalPlace = LInfo<2>
      End


      * Check that input arguments are both assigned and that data type argument is not null.
      * Otherwise return immediately.
      If UnAssigned(argTestValue) Or UnAssigned(argDataType) Or IsNull(argDataType)
      Then
         Call DSTransformError("Invalid argument(s).", RoutineName)
         RETURN(@NULL)
      End


      * NULL is valid for any data type.  Return immediately.
      If IsNull(argTestValue)
      Then
         RETURN(@TRUE)
      End


      * Decompose the data type argument.  Extract precision and scale where applicable.
      ActualDataType = Upcase(Field(argDataType, "(", 1, 1))
      DataTypeSpecs = Convert(" ", "", Field(argDataType[col2()+1,Len(argDataType)], ")", 1, 1))
      Precision = Field(DataTypeSpecs, ",", 1, 1) + 0
      Scale = Field(DataTypeSpecs, ",", 2, 1)

      If UpCase(argDataType) = "CHAR"
      Then
         Precision = 1
      End

      If Left(ActualDataType,6) = "STRING"
      Then
         DataTypeSpecs = Field(Field(argDataType, "[", 2, 1), "]", 1, 1)
         If UpCase(DataTypeSpecs[1,3]) = "MAX" Or ActualDataType = "STRING"
         Then
            ActualDataType = "VARCHAR"
         End
         Else
            ActualDataType = "CHAR"
         End
         Precision = Oconv(DataTypeSpecs, "MCN") + 0
      End



      * Build list of supported data types in COMMON variable so that it is only built once.
      COMMON /IsValid/ SupportedDataTypes
      If SupportedDataTypes = 0
      Then
         SupportedDataTypes = ""
         GoSub BuildSupportedDataTypesList
      End
$IFDEF TESTING
      SupportedDataTypes = ""
      GoSub BuildSupportedDataTypesList
$ENDIF

      Locate ActualDataType In SupportedDataTypes Setting PositionInList
      Then

         On PositionInList GoSub UInt8, Int8, Int8, UInt16, Int16, Int16, UInt32, Int32, Int32, Int32, UInt64, Int64, Int64, CharN, VarCharN, VarCharN, Decimal, Decimal, Decimal, Float, Float, Float, Float, Date, Time, Timestamp

      End
      Else

         Ans = @NULL
         Call DSTransformError("Unsupported data type.", RoutineName)

      End

      RETURN(Ans)


BuildSupportedDataTypesList:

      SupportedDataTypes<-1> = "UINT8"
      SupportedDataTypes<-1> = "INT8"
      SupportedDataTypes<-1> = "TINYINT"
      SupportedDataTypes<-1> = "UINT16"
      SupportedDataTypes<-1> = "INT16"
      SupportedDataTypes<-1> = "SMALLINT"
      SupportedDataTypes<-1> = "UINT32"
      SupportedDataTypes<-1> = "INT32"
      SupportedDataTypes<-1> = "INT"
      SupportedDataTypes<-1> = "INTEGER"
      SupportedDataTypes<-1> = "UINT64"
      SupportedDataTypes<-1> = "INT64"
      SupportedDataTypes<-1> = "BIGINT"
      SupportedDataTypes<-1> = "CHAR"
      SupportedDataTypes<-1> = "VARCHAR"
      SupportedDataTypes<-1> = "VARCHAR2"
      SupportedDataTypes<-1> = "DECIMAL"
      SupportedDataTypes<-1> = "NUMERIC"
      SupportedDataTypes<-1> = "NUMBER"
      SupportedDataTypes<-1> = "FLOAT"
      SupportedDataTypes<-1> = "REAL"
      SupportedDataTypes<-1> = "DFLOAT"
      SupportedDataTypes<-1> = "DOUBLE"
      SupportedDataTypes<-1> = "DATE"
      SupportedDataTypes<-1> = "TIME"
      SupportedDataTypes<-1> = "TIMESTAMP"

      RETURN(0)

UInt8:
      * Unsigned eight-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt8))
      RETURN(Ans)

Int8:
      * Signed eight-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinTinyInt : "," : MaxTinyInt))
      RETURN(Ans)

UInt16:
      * Unsigned 16-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt16))
      RETURN(Ans)

Int16:
      * Signed 16-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinSmallInt : "," : MaxSmallInt))
      RETURN(Ans)

UInt32:
      * Unsigned 32-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt32))
      RETURN(Ans)

Int32:
      * Signed 32-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinInteger : "," : MaxInteger))
      RETURN(Ans)


UInt64:
      * Unsigned 64-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt64))
      RETURN(Ans)

Int64:
      * Signed 64-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinBigInt : "," : MaxBigInt))
      RETURN(Ans)

CharN:
      * Character string of length N
      Ans = (Len(argTestValue) = Precision)
      RETURN(Ans)

VarCharN:
      * Character string of length less than or equal to N
      If Precision = 0
      Then
         Ans = @TRUE                     ; * string of arbitrary length; actual data type = "STRING"
      End
      Else
         Ans = (Len(argTestValue) <= Precision)
      End
      RETURN(Ans)

Decimal:
      * Decimal number with less than or equal to Precision significant digits (if Precision given) and exactly Scale decimal digits (if Scale given).
      * Note: does not presently handle "scientific notation" such as 6.023E23
      Ans = @FALSE
      If Num(argTestValue)
      Then
         If Precision = 0
         Then
            Ans = @TRUE
         End
         Else
            TestValue = argTestValue + 0           ; * remove leading and trailing zeroes, also an attempt to handle "scientific notation"
            SignificantDigits = Convert("+-", "", TestValue)           ; * remove sign
            SignificantDigits = Len(Oconv(SignificantDigits, "MCN"))   ; * count just the remaining digits
            If SignificantDigits <= Precision
            Then
               DecimalDigits = Field(argTestValue, DecimalPlace, 2, 1)
               If Len(Oconv(DecimalDigits, "MCN")) = Scale
               Then
                  Ans = @TRUE
               End
            End
         End
      End
      RETURN(Ans)

Float:
      * Any numeric value can be a floating point number.  See notes.
      Ans = Num(argTestValue)
      RETURN(Ans)

Date:
      * Date in current locale format or in ISO 8601 format (YYYY-MM-DD)
      Test1 = Iconv(argTestValue, "D")   ; * current locale
      Status1 = Status()
      Test2 = Iconv(argTestValue, "DYMD")
      Status2 = Status()
      Ans = (Status1 = 0 Or Status2 = 0)
      RETURN(Ans)

Time:
      * Time in current locale format or in ISO 8601 format (HH:MM:SS) with optional fractional seconds
      Test = Iconv(argTestValue, "MT")
      Ans = (Status() = 0)
      RETURN(Ans)

Timestamp:
      Ans = @FALSE
      If argTestValue Matches TimestampPattern
      Then
         DatePart = argTestValue[1,10]
         TimePart = argTestValue[12,8]
         Ans = IsValid(DatePart, "DATE") And IsValid(TimePart, "TIME")
      End
      RETURN(Ans)

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Here 'tis

Post by ray.wurlod »

Short Description
-----------------

Reports whether test value complies with the rules for a particular data type


Long Description
----------------

Returns NULL if either argument is not assigned or if the data type argument is null or unknown.
Always returns 1 (true) if the test value argument is null, because null is valid for any data type.
No range checking is performed for Float, Real, Double or DFloat data types; it suffices that these are numeric.
Strings containing more than 38 numeric characterse are not considered to be numeric (see BASIC manual).

Supported data types are:

Code: Select all

   uint8
   int8			tinyint
   uint16
   int16		  smallint
   uint32
   int32		  integer		int
   uint64
   int64		  bigint
   char(n)		string[n]
   varchar(n)	string[max=n]
   decimal(p,n)	numeric(p,n)	number
   float		  real
   dfloat		 double
   date
   time
   timestamp
Date and time data may be in appropriate format for current locale or in ISO 8601 format.

===========================================================================================================

Code: Select all

FUNCTION IsValid(argTestValue, argDataType)

$COPYRIGHT "Copyright (c) 2002-2006, Ray Wurlod.  All rights reserved."
$INCLUDE UNIVERSE.INCLUDE UVNLSLOC.H
$UNDEFINE TESTING

      DEFFUN IsValid(TheTestValue, TheDataType) Calling "DSU.IsValid"

      Equate RoutineName To "IsValid"

      * Constants for range checking integer data types
      Equate MinTinyInt To -2^7, MaxTinyInt To 2^7-1, MaxUInt8 To 2^8-1
      Equate MinSmallInt To -2^15, MaxSmallInt To 2^15-1, MaxUInt16 To 2^16-1
      Equate MinInteger To -2^31, MaxInteger To 2^31-1, MaxUInt32 To 2^32-1
      Equate MinBigInt To -2^63, MaxBigInt To 2^63-1, MaxUInt64 To 2^64-1

      * Pattern that all signed integers must match
      Equate IntgerPattern To "1N0N" : @VM : "'-'1N0N" : @VM : "+'1N0N"

      * Pattern that all timestamps must match: "YYYY-MM-DD HH:MM:SS" or "YYYY-MM-DD HH:MM:SS.s..."
      Equate TimestampPattern To "4N'-'2N'-'2N' '2N':'2N':'2N" : @VM : "4N'-'2N'-'2N' '2N':'2N':'2N'.'1N0N"

      * Decimal place designator (from NUMERIC locale if NLS enabled, otherwise "."
      LInfo = LocaleInfo(UVLC$NUMERIC)
      If LInfo = LCE$NO.LOCALES
      Then
         DecimalPlace = "."
      End
      Else
         DecimalPlace = LInfo<2>
      End


      * Check that input arguments are both assigned and that data type argument is not null.
      * Otherwise return immediately.
      If UnAssigned(argTestValue) Or UnAssigned(argDataType) Or IsNull(argDataType)
      Then
         Call DSTransformError("Invalid argument(s).", RoutineName)
         RETURN(@NULL)
      End


      * NULL is valid for any data type.  Return immediately.
      If IsNull(argTestValue)
      Then
         RETURN(@TRUE)
      End


      * Decompose the data type argument.  Extract precision and scale where applicable.
      ActualDataType = Upcase(Field(argDataType, "(", 1, 1))
      DataTypeSpecs = Convert(" ", "", Field(argDataType[col2()+1,Len(argDataType)], ")", 1, 1))
      Precision = Field(DataTypeSpecs, ",", 1, 1) + 0
      Scale = Field(DataTypeSpecs, ",", 2, 1)

      If UpCase(argDataType) = "CHAR"
      Then
         Precision = 1
      End

      If Left(ActualDataType,6) = "STRING"
      Then
         DataTypeSpecs = Field(Field(argDataType, "[", 2, 1), "]", 1, 1)
         If UpCase(DataTypeSpecs[1,3]) = "MAX" Or ActualDataType = "STRING"
         Then
            ActualDataType = "VARCHAR"
         End
         Else
            ActualDataType = "CHAR"
         End
         Precision = Oconv(DataTypeSpecs, "MCN") + 0
      End



      * Build list of supported data types in COMMON variable so that it is only built once.
      COMMON /IsValid/ SupportedDataTypes
      If SupportedDataTypes = 0
      Then
         SupportedDataTypes = ""
         GoSub BuildSupportedDataTypesList
      End
$IFDEF TESTING
      SupportedDataTypes = ""
      GoSub BuildSupportedDataTypesList
$ENDIF

      Locate ActualDataType In SupportedDataTypes Setting PositionInList
      Then

         On PositionInList GoSub UInt8, Int8, Int8, UInt16, Int16, Int16, UInt32, Int32, Int32, Int32, UInt64, Int64, Int64, CharN, VarCharN, VarCharN, Decimal, Decimal, Decimal, Float, Float, Float, Float, Date, Time, Timestamp

      End
      Else

         Ans = @NULL
         Call DSTransformError("Unsupported data type.", RoutineName)

      End

      RETURN(Ans)


BuildSupportedDataTypesList:

      SupportedDataTypes<-1> = "UINT8"
      SupportedDataTypes<-1> = "INT8"
      SupportedDataTypes<-1> = "TINYINT"
      SupportedDataTypes<-1> = "UINT16"
      SupportedDataTypes<-1> = "INT16"
      SupportedDataTypes<-1> = "SMALLINT"
      SupportedDataTypes<-1> = "UINT32"
      SupportedDataTypes<-1> = "INT32"
      SupportedDataTypes<-1> = "INT"
      SupportedDataTypes<-1> = "INTEGER"
      SupportedDataTypes<-1> = "UINT64"
      SupportedDataTypes<-1> = "INT64"
      SupportedDataTypes<-1> = "BIGINT"
      SupportedDataTypes<-1> = "CHAR"
      SupportedDataTypes<-1> = "VARCHAR"
      SupportedDataTypes<-1> = "VARCHAR2"
      SupportedDataTypes<-1> = "DECIMAL"
      SupportedDataTypes<-1> = "NUMERIC"
      SupportedDataTypes<-1> = "NUMBER"
      SupportedDataTypes<-1> = "FLOAT"
      SupportedDataTypes<-1> = "REAL"
      SupportedDataTypes<-1> = "DFLOAT"
      SupportedDataTypes<-1> = "DOUBLE"
      SupportedDataTypes<-1> = "DATE"
      SupportedDataTypes<-1> = "TIME"
      SupportedDataTypes<-1> = "TIMESTAMP"

      RETURN(0)

UInt8:
      * Unsigned eight-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt8))
      RETURN(Ans)

Int8:
      * Signed eight-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinTinyInt : "," : MaxTinyInt))
      RETURN(Ans)

UInt16:
      * Unsigned 16-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt16))
      RETURN(Ans)

Int16:
      * Signed 16-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinSmallInt : "," : MaxSmallInt))
      RETURN(Ans)

UInt32:
      * Unsigned 32-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt32))
      RETURN(Ans)

Int32:
      * Signed 32-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinInteger : "," : MaxInteger))
      RETURN(Ans)


UInt64:
      * Unsigned 64-bit integer
      Ans = argTestValue Matches "1N0N" And Len(Oconv(argTestValue, "R0," : MaxUInt64))
      RETURN(Ans)

Int64:
      * Signed 64-bit integer
      Ans = argTestValue Matches IntgerPattern And Len(Oconv(argTestValue, "R" : MinBigInt : "," : MaxBigInt))
      RETURN(Ans)

CharN:
      * Character string of length N
      Ans = (Len(argTestValue) = Precision)
      RETURN(Ans)

VarCharN:
      * Character string of length less than or equal to N
      If Precision = 0
      Then
         Ans = @TRUE                     ; * string of arbitrary length; actual data type = "STRING"
      End
      Else
         Ans = (Len(argTestValue) <= Precision)
      End
      RETURN(Ans)

Decimal:
      * Decimal number with less than or equal to Precision significant digits (if Precision given) and exactly Scale decimal digits (if Scale given).
      * Note: does not presently handle "scientific notation" such as 6.023E23
      Ans = @FALSE
      If Num(argTestValue)
      Then
         If Precision = 0
         Then
            Ans = @TRUE
         End
         Else
            TestValue = argTestValue + 0           ; * remove leading and trailing zeroes, also an attempt to handle "scientific notation"
            SignificantDigits = Convert("+-", "", TestValue)           ; * remove sign
            SignificantDigits = Len(Oconv(SignificantDigits, "MCN"))   ; * count just the remaining digits
            If SignificantDigits <= Precision
            Then
               DecimalDigits = Field(argTestValue, DecimalPlace, 2, 1)
               If Len(Oconv(DecimalDigits, "MCN")) = Scale
               Then
                  Ans = @TRUE
               End
            End
         End
      End
      RETURN(Ans)

Float:
      * Any numeric value can be a floating point number.  See notes.
      Ans = Num(argTestValue)
      RETURN(Ans)

Date:
      * Date in current locale format or in ISO 8601 format (YYYY-MM-DD)
      Test1 = Iconv(argTestValue, "D")   ; * current locale
      Status1 = Status()
      Test2 = Iconv(argTestValue, "DYMD")
      Status2 = Status()
      Ans = (Status1 = 0 Or Status2 = 0)
      RETURN(Ans)

Time:
      * Time in current locale format or in ISO 8601 format (HH:MM:SS) with optional fractional seconds
      Test = Iconv(argTestValue, "MT")
      Ans = (Status() = 0)
      RETURN(Ans)

Timestamp:
      Ans = @FALSE
      If argTestValue Matches TimestampPattern
      Then
         DatePart = argTestValue[1,10]
         TimePart = argTestValue[12,8]
         Ans = IsValid(DatePart, "DATE") And IsValid(TimePart, "TIME")
      End
      RETURN(Ans)

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.
novneet
Participant
Posts: 28
Joined: Tue Jan 17, 2006 2:19 pm
Location: PUNE(INDIA)

Date Conversion warning

Post by novneet »

Hi,

I used the IsValid() function in the same way as descibed above.

IsValid("date [%yyyy%mm%dd]", Ln_pour_controle.date_creation)

But the problem which I m facing with this is that whenver a Invalid date passes through the date conversion function it throws a warning, which I don't want. Is their any way, so that warning dosen't appear at all?
Or is their any other way to validate the date?

Thanks
Regards,
Novneet Jain
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

If you test for validity before applying the conversion function, and only apply the conversion function to valid dates, then the warnings will not appear.

You have to specify, and then design, what happens to rows in which the date is not a valid format.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply