|
Get Date In String YYYYMMDD Format In Server Job |
|
|
|
Written by Roceller Alvarez
|
|
Thursday, 16 March 2006 |
|
Here's a quick tip on how to get a date in string YYYYMMDD format from ETL DataStage server job. Apparently using Oconv(@DATE, "DYMD[4,2,2]") will not produce a date in YYYYMMDD format as expected. It will produce YYYY MM DD (with space in between).
There are various simple solutions but the most efficient one is the use of Trim.
Trim(Oconv(@DATE, "DYMD[4,2,2]")," ","A")
Oconv Syntax:
Oconv(expression, conversion [@VM conversion] ...)
expression is a string stored in internal format that you want to convert to an output format. If expression is a null value, null is returned.
conversion is one or more conversion codes specifying how the string is to be formatted. Separate multiple codes with a value mark. If conversion is a null value, it generates a run-time error.
Trim Syntax:
Trim (string) Trim (string, character [ ,option] )
string is a string containing unwanted characters. If string is a null value, null is returned.
character specifies a character to be trimmed (other than a space or tab). If character is a null value, it causes a run-time error.
option specifies the type of trim operation and can be one of the following:
L Removes leading occurrences of character.
T Removes trailing occurrences of character.
B Removes leading and trailing occurrences of character.
R Removes leading and trailing occurrences of character, and reduces multiple occurrences to a single occurrence.
A Removes all occurrences of character.
F Removes leading spaces and tabs
E Removes trailing spaces and tabs
D Removes leading and trailing spaces and tabs, and reduces multiple spaces and tabs to single ones.
If option is not specified or is a null value, R is assumed.
|