If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > difference of dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-07, 14:34
mandla.srinivas mandla.srinivas is offline
Registered User
 
Join Date: Jan 2007
Posts: 6
difference of dates

In what way I can get the difference of 2 dates in months.

say
date1 is '04/23/2006'
and
date2 is '02/23/2005'

The difference between these 2 dates is 14 months.
writing which query I could get this result.
Could you please help us in getting the query
Reply With Quote
  #2 (permalink)  
Old 01-05-07, 17:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Simple statement like
Code:
values date('04/23/2006') - date('02/23/2005')
will give you a number like "10200", where "1" is the number of full years, "02" is the number of months, and "00" is the number of days between the two dates. It should be easy to calculate the number of months from there.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On