Saturday, 8 February 2014

ICONV, OCONV

ICONV and OCONV functions are quite often used to handle data in Datastage.
ICONV converts a string to an internal storage format and OCONV converts an expression to an output format.

Syntax:
           Iconv (stringconversion code
           Oconv(expressionconversion 

<Karthi> This function available only in server job, not in parallel jobs.


ICONV

The following example show date conversions from external to internal format. All of these ICONV functions return the internal date 14143:

DateConversions:
  PRINT ICONV("20 SEP 2006","D")
  PRINT ICONV("09-20-2006","D")
  PRINT ICONV("09/20/2006","D")
The following example shows time conversions from external to internal format:

TimeConversions:
  PRINT ICONV("13:21","MT");       ! Returns 48060
  PRINT ICONV("1:21PM","MT");      ! Returns 48060
  PRINT ICONV("13:21:01","MT");    ! Returns 48061
  PRINT ICONV("13:21:01.65","MT"); ! Returns 48061.65

OCONV

The following example shows date conversions:

DateConversions:
  ! Month Abbreviation Formats:
  PRINT OCONV(0,"D");       ! "31 DEC 1967"
  PRINT OCONV(14100,"D");   ! "08 AUG 2006"
  PRINT OCONV(14100,"D2");  ! "08 AUG 06"
  PRINT OCONV(DATE(),"D");  ! current date in above format
  PRINT OCONV(@DATE,"D");   ! current date in above format
  PRINT OCONV(14120,"D-")   ! "08-28-2006"
  PRINT OCONV(14120,"D/")   ! "08/28/2006"
  PRINT OCONV(14120,"DE")   ! "28/08/2006"
  PRINT OCONV(14120,"D2/")  ! "08/28/06"
  PRINT OCONV(14120,"D2-E") ! "28-08-06"
The following example shows time conversions:

TimeConversions:
  PRINT OCONV(0,"MT")
  PRINT OCONV(TIME(),"MT")
  PRINT OCONV(TIME(),"MTH")
  PRINT OCONV(TIME(),"MTS")
  PRINT OCONV(TIME(),"MTS.")
  PRINT OCONV(TIME(),"MTHS*")

No comments:

Post a Comment