|
View previous topic :: View next topic
|
| Author |
Message |
mallikannasagaram
New User
Joined: 21 Feb 2006 Posts: 9 Location: india
|
|
|
|
Hi,
I have a requirement in which i need to calculate the difference between two dates interms of months. Is there any possibility of finding the difference using DB2 query?Please let me know the query if there is a way of finding it.
Thanks,
Mallik |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please post what you are using as input and how you want the output to be presented. |
|
| Back to top |
|
 |
mallikannasagaram
New User
Joined: 21 Feb 2006 Posts: 9 Location: india
|
|
|
|
Hi,
The input is 2 different dates.
Here is the example for better understanding:
Date 1 = '2007-09-10'
Date 2 = '2006-12-22'
Then my output should be 9 months.
Thanks,
Mallik |
|
| Back to top |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
| mallikannasagaram wrote: |
Hi,
The input is 2 different dates.
Here is the example for better understanding:
Date 1 = '2007-09-10'
Date 2 = '2006-12-22'
Then my output should be 9 months.
Thanks,
Mallik |
The results of subtracting 2 date using DB2 is a signed 8 digit number (yyyymmdd), you can use that to calculate the number of months (yyyy * 12) + mm. |
|
| Back to top |
|
 |
mallikannasagaram
New User
Joined: 21 Feb 2006 Posts: 9 Location: india
|
|
|
|
Hi Crag,
can you explain it with example?
Thanks,
Mallik |
|
| Back to top |
|
 |
|
|