| DATE | Returns the current date in the pattern YYMMDD |
| DATETIME | Returns the current date and time in the user-specified pattern or in the default pattern YYYYMMDDHHMISS999 |
| DAYS | Returns the number of days corresponding to a date/time pattern string, or the number of days for today's date |
| DAYSTODATE | Converts a number of days to a date/time pattern string |
| DAYSTOSECS | Converts a number of days to a number of seconds |
| REPATTERN | Takes a value holding a date in one pattern and returns that value converted to a date in a second pattern |
| SECS | Returns the number of seconds corresponding to a date/time pattern string, or the number of seconds for today's date |
| SECSTODATE | Converts a number of seconds to a date/time pattern string |
| SECSTODAYS | Converts a number of seconds to a number of days |
| TIME | Returns the current time in the pattern HHMISS999 |
| VALIDDATE | Indicates if a string holds a valid date |
| WEEKDAY | Returns the day of the week corresponding to the current day or specified DAYS value |
| Y4DATE | Takes a date value with the pattern 'YYMMDD' and returns the date value with the two-digit year widened to a four-digit year |
| Y4JULIAN | Takes a date value with the pattern 'YYDDD' and returns the date value with the two-digit year widened to a four-digit year |
| Y4YEAR | Takes a date value with the pattern 'YY' and returns the date value with the two-digit year widened to a four-digit year |
Showing posts with label BUILTIN Functions. Show all posts
Showing posts with label BUILTIN Functions. Show all posts
Thursday, September 13, 2012
DATE/TIME BUILT IN FUCNCTIONS
TRANSLATE
TRANSLATE : SUBSTITUTES ONE CHARACTER/BIT WITH ANOTHER
SYNTAX: TRANSLATE(X,Y,Z)
X = SOURCE STRING
Y = REPLACEMENT STRING
Z = POSITION STRING
EX: TRANSLATE(X, Y, Z);
X= '1GOLDEN'
Y='ABCSILVER'
Z='WXYGOLDEN'
NOW FOR EACH CHARACTER OF X, A SEARCH OF Z IS MADE AND IF MATCH IS FOUND THE CORRESPONDING POSITIONAL CHARACTER IN Y IS RETURNED.
SO AFTER EXECUTING TRANSLATE(X,Y,Z), THE X BECOMES '1SILVER'
REPEAT
IT TAKES A GIVEN STRING VALUE AND FORMS A NEW STRING CONSISTING OF STRING VALUE CONCATENATED WITH ITSELF A SPECIFIED NUMBER OF TIMES.
SYNTAX: REPEAT ( M, N )
M = STRING THAT HAS TO BE REPEATED
N = DECIMAL INTEGER CONSTANT/VARIABLE THAT MUST BE GREATER THAN '0'
EX: REPEAT('HYDERABAD ', 2) RESULTS IN 'HYDERABAD HYDERABAD'
SYNTAX: REPEAT ( M, N )
M = STRING THAT HAS TO BE REPEATED
N = DECIMAL INTEGER CONSTANT/VARIABLE THAT MUST BE GREATER THAN '0'
EX: REPEAT('HYDERABAD ', 2) RESULTS IN 'HYDERABAD HYDERABAD'
VERIFY
VERIFY returns a FIXED value indicating the position in x of the leftmost character that is not in y. It also allows you to specify the location within x at which to begin processing.
VERIFY(x,y,n) |
- x
- Expression.x should have CHARACTER type, and if not, it is converted thereto.
- y
- Expression.y should have CHARACTER type, and if not, it is converted thereto.
- n
- Expression n specifies the location within x where processing begins.n should have FIXED type, and if not, it is converted thereto.
n must be greater than 0 and no greater than 1 + LENGTH(x).
If n = LENGTH(x) + 1, the result is zero.
INDEX
INDEX returns the starting position of a substring within a string.
BACK is an optional parameter/argument.
INDEX(STRING,SUBSTRING,BACK)
EX:
1. INDEX('FORTRAN', 'R') has the value 3 2. INDEX('FORTRAN', 'R',BACK=TRUE) has the value 5 |
Case (i): If BACK is absent or present with the value .FALSE., the result is the minimum positive value of I such that STRING (I : I + LEN (SUBSTRING) - 1) = SUBSTRING or zero if there is no such value. Zero is returned if LEN (STRING) < LEN (SUBSTRING). One is returned if LEN (SUBSTRING) = 0.
Case (ii): If BACK is present with the value .TRUE., the result is the maximum value of I less than or equal to LEN (STRING) - LEN (SUBSTRING) + 1, such that STRING (I : I + LEN (SUBSTRING) - 1) = SUBSTRING or zero if there is no such value. Zero is returned if LEN (STRING) < LEN (SUBSTRING) and LEN (STRING) + 1 is returned if LEN (SUBSTRING) = 0.
Sunday, September 9, 2012
SUBSTR
The SUBSTR built-in function is of particular importance since it is a basic PL/1 string operator. It is a three argument function which allows a reference to be made to a portion of a string variable, i.e., SUBSTR (a, b,c) is a reference to the bth through b + c -1th character (or bit) in the string a.
SUBSTR returns a substring, specified by b and c, of a.
|
- a
- String expression. It specifies the string from which the substring is extracted. If a is not a string, it is converted to character.
- b
- Expression that is converted to FIXED BINARY(31,0). b specifies the starting position of the substring in a.
- c
- Expression that is converted to FIXED BINARY(31,0). c specifies the length of the substring in a. If c is zero, a null string is returned. If c is omitted, the substring returned is position b in a to the end of a.
The STRINGRANGE condition is raised if c is negative or if the values of b and c are such that the substring does not lie entirely within the current length of a. It is not raised when b = LENGTH(a)+1 and c = 0.
Subscribe to:
Posts (Atom)