DB2

DB2 is IBM's offering to the highend database market. The latest version of DB2 (Universal Database) is ideal for OLTP, Data Warehousing, Decision Support and everything in between. It's well priced, extremely scalable and runs on virtually every platform out there from handhelds to mainframes.

Subtract 2 decimal values representing dates


Good morning,
I have 2 fields that are Dec 8,0 and they represent a date in YYYYMMDD. I want to subtract one from the other, always knowing that the first date is greater than the second. the dates represent when something got recieved (podt00) minus when it shipped (rddt00) to get a number of days result.
I am trying this:
DAYs(date(podt00)) - DAYs(date(rddt00))
any help would be appreciated.
Thank you.
Originally Posted by 64waves
any help would be appreciated.
Sure. http://www.dbforums.com/db2/854783-m...e-posting.html
Iseries
V5R4M0
Maybe you have to do something like this:
Code:
select DATE(left(varchar(int(20020311.)), 4)
|| '-' || substr(varchar(int(20020311.)), 5, 2)
|| '-' || right(varchar(int(20020311.)), 2))
from sysibm.sysdummy1
Another expressions.
Code:
, DATE( INSERT(INSERT(DIGITS(podt00) , 5 , 0 , '-') , 8 , 0 , '-') ) AS two_insert
, DATE( TRANSLATE('abcd-ef-gh' , DIGITS(podt00) , 'abcdefgh') ) AS translate
Originally Posted by tonkuma
Another expressions.
Code:
, DATE( INSERT(INSERT(DIGITS(podt00) , 5 , 0 , '-') , 8 , 0 , '-') ) AS two_insert
, DATE( TRANSLATE('abcd-ef-gh' , DIGITS(podt00) , 'abcdefgh') ) AS translate
I like how you are using translate function. Just a small change (for better look):
Code:
select TRANSLATE('year-mo-dt' , varchar(podt00) , 'yearmodt')
from (select 20120312 as podt00
from sysibm.sysdummy1 ) aa
Lenny
Nice! Lenny.
'year-mo-dt' is charming for me than plain 'abcd-ef-gh'.

Related Links

DB2 Performance problem
Fetch in DB2 stored procedure
how can I start "db2cc"!
query optimizer runs astray....
Migration AS/400 DB2 to Windows DB2 8.1
Creating a new database with the existing database with same structure
load error SQL0302N
load error SQL0302N
Db2 Udb Unix Aix
Dropping and recreating a primary key which has already unique index
Strange installation problem - please help!
DB2 Varchar characters truncated
ZRC=0x805C012D
How to pivot dates into columns?
Task center problem
can i use the list tablespaces command in a procedure

Categories

DataBase Dev
MongoDB
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
Crystal Reports
Delphi, C etc
JAVA
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
Brilliant Database
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
New Members & Introduc...
Applications & Tools
Database Concepts & De...
Chit Chat
Marketplace
Job Opportunities
Suggestions & Feedback

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App