Special Date Calculation ...

Discussion in 'Programming' started by pepe_lepew1962, Feb 19, 2011.

  1. #1
    Hello, I REALLY need some help creating a special date calculation. I want to calculate the difference between 2 mysql fields but display the difference as:
    //
    //
    02:19:21
    //
    02 is days
    19 is hours
    21 as minutes
    //
    //
    $Dater01 = $row['tblTabler00_Dater01']; //2010-12-16 23:45:00
    $Dater02 = $row['tblTabler00_Dater02']; //2010-12-14 04:24:00
    //
    $Dater03 = $Dater01 - $Dater02
    //
    Important is that a negative amount is valid, meaning it is overdue. Any help would be greatly appreciated.
    //
    Regards,
     
    pepe_lepew1962, Feb 19, 2011 IP
  2. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's pretty easy in vbscript. Use the DateDiff function. You specify an interval to return the result in (years, or months, or days, or hours, etc) and the two dates.

    Example: DateDiff("d", Now, dueDate) returns the number of days.

    There's are details here: http://msdn.microsoft.com/en-us/library/xhtyw595(v=VS.85).aspx
     
    longcall911, Feb 20, 2011 IP