Results 1 to 3 of 3

Thread: DATE CALCULATIONS FOR ADO DB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    68

    Question


    does anybody know a way to calculate the age of a record.

    I am writing a call logging system, and as each call is recieved a field in the calls table is used to store the date and time ( using the vb NOW function )

    What the system does at a later point is queries the database and gets all outstanding calls.

    I then grab the oldest call, and I need to be able to say how old the call is in DAYS, HOURS and Minutes.

    But I am not sure how to do this, is there a vb funstion to carry out the calculation?

    IE:

    Outstanding = NOW - OLDDATE

    ANY IDEAS!!!
    THE DOUGSTER!!!!!!


    *-MCSD-*

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'will give you the days
    'my var = your mdb field
    myVar = "9/01/2000 7:40:08 AM"

    MsgBox "Days from today: " & DateDiff("d", myVar, Now)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Form_Load()
    
        Dim myvar As Date
        'my var = your mdb field
        myvar = "9/01/2000 7:40:08 AM"
        
        Dim mHour As Double, mMin As Double, mSec As Double
        
        mHour = DateDiff("h", myvar, Now)
        mMin = DateDiff("m", myvar, Now)
        mSec = DateDiff("s", myvar, Now)
        
        Dim myTimeGone As String
        
        myTimeGone = "   Hours =    " & mHour & ":" & "   Minuites =    " & mMin & ":" & "   Seconds =    " & mSec
        
        MsgBox myTimeGone
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width