Results 1 to 4 of 4

Thread: Time Conversion

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Time Conversion

    Hi
    well i want to calculate the number of minutes present in this time ( 23:45:06 )
    this is time is in one cell .. i need a formula to put in another cell so that i can get the total number of minutes
    Regards

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Time Conversion

    Something along these line:
    VB Code:
    1. MsgBox DateDiff("s", "00:00:00", "23:45:06")

    Yeilds: 85506 (Seconds sine midnight).
    Last edited by Bruce Fox; Jun 18th, 2006 at 09:36 PM.

  3. #3
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Time Conversion

    Here is a step-by-step process to help you understand what you are trying to do ... convert a Date/Time value to a floating point number:

    daysInteger.dayFraction

    If daysInteger is 0, then the dayFraction * 24 = Hours and dayFraction * 24 * 60 = Minutes.
    Code:
    Option Explicit
    Sub Macro1()
        Dim aTime As Date
        Dim myHours As Double
        Dim myMinutes As Double
        
        'Initialize a Date/Time value
        aTime = "23.49.22"
        'Convert to Hours and Minutes
        myHours = CDbl(aTime) * 24#  ' 24# = 24.0
        myMinutes = myHours * 60#    ' 60# = 60.0
        'Here are the results
        MsgBox myHours & "  " & myMinutes
        
    End Sub
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Time Conversion

    Code:
    =(HOUR(B4)*60)+MINUTE(B4)+(SECOND(B4)/60)
    B4 holding the time.

    Wasn't a coding question - sounds more like a classroom question - using normal functions.

    Code:
    Code:
    ?cdbl(cdate("23:45:06"))*24*60
    (same as webtests! - sorry!)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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