English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to convert a decimal 20060901 to the Date 2006-09-01 (YYYY-MM-DD) and then subtract 2 days to get date : 2006-08-30.
In Oracle when I run the following Query it works:

SELECT TO_DATE('2006-09-01', 'YYYY-MM-DD') - 2
FROM DUAL
but I do not know how to do the same in DB2

2006-09-05 02:11:51 · 1 answers · asked by vusimhl 2 in Computers & Internet Programming & Design

1 answers

What you are looking for is the Char function which allows you to format the date to ISO, USA, EUR, JIS, and LOCAL formats

The command that you want is
SELECT CHAR((DateColumn - 2 days), iso)
FROM etc...

The word DAYS following the 2 translates the 2 into a value that can be subtracted from a date. You can also have day, month, months, year and years

2006-09-05 03:06:26 · answer #1 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers