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 Command Centre
One or more values in the INSERT statement, UPDATE statement, or foreign key update c
The cursor specified in a FETCH or CLOSE statement is not open
test
db2 security
online incremental backups in DB2
DB2 stored procedures filesystem full errors
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E Function sequence error. SQ
problems with DB2 Administration server
st
Adding space to SMS tablespaces - alternatives?
db2inidb through API
How to obtain a lock on the table
Activate not logged initially issue
Page cleaners Tuning
PHP and db2diag command

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