+ Reply to Thread
Results 1 to 5 of 5

Extracting first two digits of a time entry!!

  1. #1
    Registered User
    Join Date
    05-30-2006
    Posts
    33

    Extracting first two digits of a time entry!!

    HI friends,
    Could anyone tell me how to extract first two digits of a "Time value"

    For example in cell B10 the content is 12:00 ie..(Time)
    I am not able to extract "12" ie the first two digits of that time.

    I am getting 0.5013 when taken as text.


    Regards,
    TIA


    Roshin

  2. #2
    Mike
    Guest

    Re: Extracting first two digits of a time entry!!

    roshinpp_77 wrote:

    > HI friends,
    > Could anyone tell me how to extract first two digits of a "Time
    > value"
    >
    > For example in cell B10 the content is 12:00 ie..(Time)
    > I am not able to extract "12" ie the first two digits of that time.
    >
    > I am getting 0.5013 when taken as text.
    >
    >
    > Regards,
    > TIA
    >
    >
    > Roshin
    >
    >

    Hello,
    use this left(range("B10").text,2)

    Mike,Luxembourg

  3. #3
    Xcelion
    Guest

    RE: Extracting first two digits of a time entry!!

    Hi Roshin,

    Try this
    =LEFT(TEXT(B10,"hh:mm"),2)

    --
    Thanks
    Xcelion



    "roshinpp_77" wrote:

    >
    > HI friends,
    > Could anyone tell me how to extract first two digits of a "Time
    > value"
    >
    > For example in cell B10 the content is 12:00 ie..(Time)
    > I am not able to extract "12" ie the first two digits of that time.
    >
    > I am getting 0.5013 when taken as text.
    >
    >
    > Regards,
    > TIA
    >
    >
    > Roshin
    >
    >
    > --
    > roshinpp_77
    > ------------------------------------------------------------------------
    > roshinpp_77's Profile: http://www.excelforum.com/member.php...o&userid=34924
    > View this thread: http://www.excelforum.com/showthread...hreadid=569321
    >
    >


  4. #4
    NickHK
    Guest

    Re: Extracting first two digits of a time entry!!

    Depending what you actually want returned, a string or a number.
    Assuming the value is a double formatted as a time:
    Public Function GetHourOnly(argRange As Range) As Integer
    GetHourOnly = Int(argRange.Value * 24)
    End Function
    Or
    Public Function GetHourOnly(argRange As Range) As String
    GetHourOnly = Left(argRange.Text, 2)
    End Function

    NickHK

    "roshinpp_77" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > HI friends,
    > Could anyone tell me how to extract first two digits of a "Time
    > value"
    >
    > For example in cell B10 the content is 12:00 ie..(Time)
    > I am not able to extract "12" ie the first two digits of that time.
    >
    > I am getting 0.5013 when taken as text.
    >
    >
    > Regards,
    > TIA
    >
    >
    > Roshin
    >
    >
    > --
    > roshinpp_77
    > ------------------------------------------------------------------------
    > roshinpp_77's Profile:

    http://www.excelforum.com/member.php...o&userid=34924
    > View this thread: http://www.excelforum.com/showthread...hreadid=569321
    >




  5. #5
    Dave Peterson
    Guest

    Re: Extracting first two digits of a time entry!!

    You can extract the hour, minute or second:

    With ActiveSheet.range("B10")
    MsgBox Hour(.Value) & vbLf & _
    Minute(.Value) & vbLf & _
    Second(.Value)
    End With



    roshinpp_77 wrote:
    >
    > HI friends,
    > Could anyone tell me how to extract first two digits of a "Time
    > value"
    >
    > For example in cell B10 the content is 12:00 ie..(Time)
    > I am not able to extract "12" ie the first two digits of that time.
    >
    > I am getting 0.5013 when taken as text.
    >
    > Regards,
    > TIA
    >
    > Roshin
    >
    > --
    > roshinpp_77
    > ------------------------------------------------------------------------
    > roshinpp_77's Profile: http://www.excelforum.com/member.php...o&userid=34924
    > View this thread: http://www.excelforum.com/showthread...hreadid=569321


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1