Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Differences 1

Status
Not open for further replies.

Dagon

MIS
Jan 30, 2002
2,301
GB
I want to find the number of days between one date and another. DB2 can subtract dates and it gives me:

YYMMDD

I'd like to convert this to a number of days using (yy*365) + (mm*31) + dd. Unfortunately, the MM component seems to be a variable number of days depending on how long each month is (31 days, 30 days etc). It looks like that to get the number of days I'd have to go through some horrendous process of comparing the two dates and working out which months lie between them so that I can assign the correct number of days. Is there any way you can just get an absolute number of days between two dates ?
 
Select days(date1) - days(date2) as num_days from ....

HTH

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top