Questions

DATEDIFF FUNCTION

Tags:
+
0 Votes
Locked

DATEDIFF FUNCTION

tytyu67567
Hi,

Im a developer. I have a question on the DATEDIFF function, hope you can help me out. Im using DATEDIFF function, I know that it will result in integer value. But, I need the result in decimals.

For example :

STARTDATE ENDATE RESULT
8/27/2003 9/2/1976 26.11
9/1/2003 1/6/2000 3.8


CAN YOU PLEASE HELP ME ?

THANKS IN ADVANCE
  • +
    0 Votes
    LocoLobo

    you set the interval to days and divide by 365.25 store it in a decimal (single) variable?

    Is this VB?

    +
    0 Votes
    Tony Hopkinson

    and divide by 365.
    Should be near enough.

    +
    0 Votes
    rwidegren

    If you want the result to be the number of years to the left of the decimal and the number of months to the right (as a whole number) then you could do the DateDiff in months and divide by 12. The integer part would be the years and the Mod would be the extra months.

  • +
    0 Votes
    LocoLobo

    you set the interval to days and divide by 365.25 store it in a decimal (single) variable?

    Is this VB?

    +
    0 Votes
    Tony Hopkinson

    and divide by 365.
    Should be near enough.

    +
    0 Votes
    rwidegren

    If you want the result to be the number of years to the left of the decimal and the number of months to the right (as a whole number) then you could do the DateDiff in months and divide by 12. The integer part would be the years and the Mod would be the extra months.