Common Content for Data Engineering
- Common Content for Data Engineering 10.5.4
- All Products
TO_DATE(string[,format] )
Argument
| Required/
Optional
| Description
|
---|---|---|
string
| Required
| Must be a string datatype. Passes the values that you want to convert to dates. You can enter any valid transformation expression.
|
format
| Optional
| Enter a valid TO_DATE format string. The format string must match the parts of the
string argument. For example, if you pass the string 'Mar 15 1998 12:43:10AM', you must use the format string 'MON DD YYYY HH12:MI:SSAM'. If you omit the format string, the string value must be in the date format specified in the session.
|
TO_DATE( DATE_PROMISED, 'MM/DD/YY' )
|
|
---|---|
|
|
|
|
|
|
|
|
|
|
TO_DATE( DATE_PROMISED, 'MON DD YYYY HH12:MI:SSAM' )
|
|
---|---|
|
|
|
|
|
|
|
|
|
|
TO_DATE (SHIP_DATE_MJD_STR, 'J')
|
|
---|---|
|
|
|
|
TO_DATE( DATE_STR, 'MM/DD/RR')
|
|
---|---|
|
|
|
|
TO_DATE( DATE_STR, 'MM/DD/YY')
|
|
---|---|
|
|
|
|
TO_DATE( DATE_STR, 'MM/DD/Y')
|
|
---|---|
|
|
|
|
TO_DATE( DATE_STR, 'MM/DD/YYY')
|
|
---|---|
|
|
|
|
TO_DATE( DATE_STR, 'MM/DD/YYYY SSSSS')
|
|
---|---|
|
|
|
|
DECODE( TRUE, --test first format IS_DATE( CLOSE_DATE,'MM/DD/YYYY HH24:MI:SS' ), --if true, convert to date TO_DATE( CLOSE_DATE,'MM/DD/YYYY HH24:MI:SS' ), --test second format; if true, convert to date IS_DATE( CLOSE_DATE,'MM/DD/YYYY'), TO_DATE( CLOSE_DATE,'MM/DD/YYYY' ), --test third format; if true, convert to date IS_DATE( CLOSE_DATE,'MON DD YYYY'), TO_DATE( CLOSE_DATE,'MON DD YYYY'), --if none of the above ERROR( 'NOT A VALID DATE') )
TO_CHAR( TO_DATE( numeric_month, 'MM' ), 'MONTH' )