+ Reply to Thread
Results 1 to 3 of 3

Covert Time into Number

  1. #1
    Registered User
    Join Date
    03-31-2011
    Location
    Kolkata,India
    MS-Off Ver
    Excel 2003
    Posts
    22

    Covert Time into Number

    Hi All,

    In a columns I have the time like below
    18:10
    19:25
    19:52
    20:15
    21:45
    00:12
    00:23
    00:55
    01:45
    02:34
    03:36
    04:14
    05:18
    06:17

    I want to show the time 6-8 (18:00-20:00) as 1, 8-10 (20:00-22:00) as 2
    10-12 (20:00-00:00) as 3, 00:00-02:00 (00:00-02:00) as 4 and so on...

    will I have to write macro? or is there any better way to that?

    Please help!!

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Covert Time into Number

    I would use a VLOOKUP. Make a table of your times with their corresponding numbers in the next column. Start with the earliest time i.e. 0:00 and 4 through to 22:00 and 3 (See attachment)
    Then in the column next to your actual times, use this formula

    =VLOOKUP(A4,$H$3:$I$14,2)
    where A4 is your time, H3:I14 is your lookup table and 2 means return column 2.
    Does that work for you?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Covert Time into Number

    Try:

    =INT(A1*24/2)+IF(A1<TIME(18,0,0),4,-8)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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