Search results
9 sty 2015 · In DB2 9.7, you can also use the TO_DATE function (similar to Oracle's TO_DATE): date(to_date(column_with_date,'DD-MM-YYYY HH:MI:SS')) This requires your data match the formatting string; it's easier to understand when looking at it, but not as flexible as the TRANSLATE option.
In the following example, the CAST specification is used to tell Db2 to assume that the value that will be provided as input to the TIME function will be CHAR(20). See PREPARE statement for a list of contexts when invoking functions where parameter markers can be untyped.
The TO_DATE function returns a timestamp that is based on the interpretation of the input string using the specified format. TO_DATE ( string-expression , format-string , 6 , precision-constant , locale-name , locale-name , 6 , precision-constant )
If expression is not a DATE value, expression is cast as follows: If expression is a TIMESTAMP WITH TIME ZONE value, expression is cast to TIMESTAMP WITHOUT TIME ZONE, with the same precision as expression. If expression is a string, expression is cast to DATE. The result of the function is a date.
The TO_DATE function returns a timestamp value that is based on the interpretation of the input string using the specified format. TO_DATE ( string-expression , format-string , 6 , precision-constant )
You can use cast functions or CAST specification to explicitly cast a data type to another data type. For example, if you have a column of dates (BIRTHDATE) defined as DATE and want to cast the column data type to CHARACTER with a fixed length of 10, enter the following:
15 lut 2022 · The simple ISO-date can be parse like this: SELECT DATE ('1990-02-09') FROM sysibm.sysdummy1; The numeric date can be parsed by using TO_DATE scalar function and adding a format-literal as second argument: SELECT TO_DATE('199002', 'YYYYMM') FROM sysibm.sysdummy1;