I have a DB2 table where NUM column is defined as INTEGER in DB2 and the query result is shown below,
NUM columns have numeric values which needs to be converted to date format. This numeric values are nothing but duration from 01.01.1850. Example : 01.01.1850 57677 days = 01.12.2007.
So Is it possible to convert or cast the numeric value into date fields in DB2 , so that the select query from the table can result as shown below after converting a numeric field into date field,
CodePudding user response:
You may use the scalar ADD_DAYS
function:
SELECT EMP_ID, ADD_DAYS('1850-01-01', NUM) AS NUM
FROM yourTable;
CodePudding user response:
Not all Db2 products & versions have the ADD_DAYS
function.
The following expression works for all of them.
You may optionally add DAY
or DAYS
at the end.
DATE ('1850-01-01') 57677