cancel
Showing results for 
Search instead for 
Did you mean: 

return nmbr of yrs, montsh and days between two dates as one object

Former Member
0 Kudos

Rqrmt: to show the number of years, months and days between two dates.

Date1: 01/01/2005

Date2: 02/02/2010

Result to show: 1D;1M;5Y or whatever format?

Using variables within functions rolls each in total, but the days are showing all days, all months, not just "each part"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can display them as:

Total Days = Daysbetween(02/02/2010;01/01/2005)

Years = Total Days/365

Months =(Total Days - Years*365)/30

Days = Total Days - years365 - months30

Now you can combine them in 1 single variable using concat:

Final = Days"D"Months"M"Years+"Y"

Regards,

Rohit

Former Member
0 Kudos

I don't get it. Wouldn't you have to account for leap years etc? I think you would have to use a calendar table to address those types of issues.

But I admit I am not totally clear on your requirements.

Thanks

Former Member
0 Kudos

Thanks, this works great!

Would be better if there was a calendar table, however, there isn't. This is more of a manual solution, that, yes, could be better if it accounted for leap years, etc.. however, for this purpose, solution is OK!!

Thanks Rohit!

Answers (0)