473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Date Arithmatic

Hi Group ,

Am new to DB2 . I am facing some problem with date arithmatics :

The current date as today is from the below sql :

db2 "select current date from sysibm.sysdummy1"

1
----------
04/24/2007

1 record(s) selected.

I want to check out the difference between todays date and an old date
'10/15/1999'
db2 "select current date - date('10/15/1999') from sysibm.sysdummy1"

1
----------
70609.

1 record(s) selected.

What does the output 70609 indicates ...Is it no of days ?? Not
possible .

Again I checked with the below query :

pads@ibmrgzng /home/padsdb2 "select date (current date -
date('10/15/1999')) from sysibm.sysdummy1"

1
----------
04/27/0194

1 record(s) selected.

What does the out put indicates ??
Can you please help me .

Best Regards
Bikash Karan

Apr 24 '07 #1
3 4703
Ian
ka*********@gmail.com wrote:
Hi Group ,
I want to check out the difference between todays date and an old date
'10/15/1999'
db2 "select current date - date('10/15/1999') from sysibm.sysdummy1"

1
----------
70609.

It's called a date duration. It displays the difference in years,
months and days. So, in your example, it's 7 years, 06 months, 09 days.
Apr 24 '07 #2
On Apr 24, 11:52 am, Ian <ianb...@mobileaudio.comwrote:
karanbik...@gmail.com wrote:
Hi Group ,
I want to check out the difference between todays date and an old date
'10/15/1999'
db2 "select current date - date('10/15/1999') from sysibm.sysdummy1"
1
----------
70609.

It's called a date duration. It displays the difference in years,
months and days. So, in your example, it's 7 years, 06 months, 09 days.


Thanks a lot ....and how about if I modify the query as

$db2 "select date(current date - date('10/15/1999')) from
sysibm.sysdummy1"

1
----------
04/27/0194

1 record(s) selected.
What does this format shows ??
Thanks a lot .

Apr 24 '07 #3
date duration's actual data type is DECIMAL(8,0).
DATE function takes as its argument some different data types and the
result depend on the argument's data type, length and format(if
argument is a character string).
In this example argument is a number(calculated as date duration),
then DATE returns n-1 days after January 1, 0001.
There is another function DAYS which take arguments as date or
timestamp or character representation of them and returns days from
January 1, 0001.
------------------------- Commands Entered -------------------------
VALUES current date - date('10/15/1999');
-------------------------------------------------------------------

1
----------
70609.

1 record(s) selected.
------------------------- Commands Entered -------------------------
VALUES date(current date - date('10/15/1999'));
--------------------------------------------------------------------

1
----------
0194-04-27

1 record(s) selected.
------------------------ Commands Entered -------------------------
VALUES DAYS('04/27/0194');
-------------------------------------------------------------------

1
-----------
70609

1 record(s) selected.

If you want the days between '10/15/1999' and current date, you can
calculate as followings.
------------------------- Commands Entered -------------------------
VALUES DAYS(current date) - DAYS('10/15/1999');
------------------------------------------------------------------------

1
-----------
2748

1 record(s) selected.

Apr 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
9
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very clean. I've come up with some rules that I think...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
3
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
2
by: sapnakiran | last post by:
Can u tell me how can we build up arithmatic operation without using arithmatic operator
8
upadhyad
by: upadhyad | last post by:
Hi all!! i am relatively new to c... and I need to help urgently! i have date and time in 2 separate strings. i have parsed them. eg I had 26.2.2007 and I parsed it so that i have day month and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.