• Dennis Wagner-347763 (1/16/2014)


    Do you have a good query for formatting duration (or age) in Years, Months, Days?

    So often in my world, I am asked to find out who was the youngest or oldest to achieve something, or how long has it been since something has been achieved in a span of that range. I have a function that will do it, but I'd be interested to see how others have done it.

    Of course I know that not all months have 30 days, so saying that someone is 16 years, 8 months, and 7 days old could be equivalent to 16 years, 8 months, and 10 days if months with 31 and 28 days are involved in the calculation. You also cannot just assume that a month is 30 days in your calculation since you could end up with 16 years, 12 months, and 4 days which would immediately look ridiculous and completely destroy your credibility. Number of days is the truest measure for comparison, but telling someone that the youngest was 6095 days old has no meaning to most people.

    Anyone out there got a good method for YMD?

    Which years in the calendar should we use to calculate this? The actual span between the two dates? Then comparisons between calculations made from different pairs of dates are not strictly compatible. The biggest reason is the occurrence of leap years within ranges. It might may a difference of only a day, but it sounds like for your applications, that may be important.

    But, you could just do three DATEPART calculations and be done with it.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn