+ Reply to Thread
Results 1 to 5 of 5

Time as number

  1. #1
    Howard
    Guest

    Time as number

    I'm working on a time card where employees enter time in, out for lunch, back
    in and out for the day. I can do this in a time format and get the total for
    the day. However, the manager thinks it's too cumbersome for employees to
    type 8:00 AM, 1:00 PM, 2:00 PM, 5:00 PM, for example. Is there a way to do
    this using numbers, other than military time, or not having to type AM or PM?

    Thanks,
    --
    Howard

  2. #2
    Gary's Student
    Guest

    RE: Time as number

    Try the following UDF:

    Function time_it(simple_time As Integer)
    Dim hr As Integer
    Dim min As Integer
    hr = Int(simple_time / 100)
    min = simple_time - hr * 100
    If hr < 6 Then
    hr = hr + 12
    End If
    MsgBox (hr)
    MsgBox (min)
    time_it = TimeSerial(hr, min, 0)
    End Function

    Put the function in cells formatted as time.
    time_it(800) will return 8:00 AM
    time_it(1000) will return 10:00 AM
    but
    time_it(100) will return 1:00PM
    --
    Gary's Student


    "Howard" wrote:

    > I'm working on a time card where employees enter time in, out for lunch, back
    > in and out for the day. I can do this in a time format and get the total for
    > the day. However, the manager thinks it's too cumbersome for employees to
    > type 8:00 AM, 1:00 PM, 2:00 PM, 5:00 PM, for example. Is there a way to do
    > this using numbers, other than military time, or not having to type AM or PM?
    >
    > Thanks,
    > --
    > Howard


  3. #3
    Howard
    Guest

    RE: Time as number

    Gary's Student,
    Thanks very much! I'll try it.
    --
    Howard


    "Gary's Student" wrote:

    > Try the following UDF:
    >
    > Function time_it(simple_time As Integer)
    > Dim hr As Integer
    > Dim min As Integer
    > hr = Int(simple_time / 100)
    > min = simple_time - hr * 100
    > If hr < 6 Then
    > hr = hr + 12
    > End If
    > MsgBox (hr)
    > MsgBox (min)
    > time_it = TimeSerial(hr, min, 0)
    > End Function
    >
    > Put the function in cells formatted as time.
    > time_it(800) will return 8:00 AM
    > time_it(1000) will return 10:00 AM
    > but
    > time_it(100) will return 1:00PM
    > --
    > Gary's Student
    >
    >
    > "Howard" wrote:
    >
    > > I'm working on a time card where employees enter time in, out for lunch, back
    > > in and out for the day. I can do this in a time format and get the total for
    > > the day. However, the manager thinks it's too cumbersome for employees to
    > > type 8:00 AM, 1:00 PM, 2:00 PM, 5:00 PM, for example. Is there a way to do
    > > this using numbers, other than military time, or not having to type AM or PM?
    > >
    > > Thanks,
    > > --
    > > Howard


  4. #4
    Gary's Student
    Guest

    RE: Time as number

    Discard the MsgBox statements. They were only for debugging.
    --
    Gary's Student


    "Howard" wrote:

    > Gary's Student,
    > Thanks very much! I'll try it.
    > --
    > Howard
    >
    >
    > "Gary's Student" wrote:
    >
    > > Try the following UDF:
    > >
    > > Function time_it(simple_time As Integer)
    > > Dim hr As Integer
    > > Dim min As Integer
    > > hr = Int(simple_time / 100)
    > > min = simple_time - hr * 100
    > > If hr < 6 Then
    > > hr = hr + 12
    > > End If
    > > MsgBox (hr)
    > > MsgBox (min)
    > > time_it = TimeSerial(hr, min, 0)
    > > End Function
    > >
    > > Put the function in cells formatted as time.
    > > time_it(800) will return 8:00 AM
    > > time_it(1000) will return 10:00 AM
    > > but
    > > time_it(100) will return 1:00PM
    > > --
    > > Gary's Student
    > >
    > >
    > > "Howard" wrote:
    > >
    > > > I'm working on a time card where employees enter time in, out for lunch, back
    > > > in and out for the day. I can do this in a time format and get the total for
    > > > the day. However, the manager thinks it's too cumbersome for employees to
    > > > type 8:00 AM, 1:00 PM, 2:00 PM, 5:00 PM, for example. Is there a way to do
    > > > this using numbers, other than military time, or not having to type AM or PM?
    > > >
    > > > Thanks,
    > > > --
    > > > Howard


  5. #5
    Forum Contributor
    Join Date
    10-14-2004
    Location
    San Diego, CA
    Posts
    213
    Hello Howard:

    This formula will return the time value of a three digit or for digit number using
    the military time format without having to enter ( : ) between the numbers.

    =IF(LEN(A1)=3,TIME(LEFT(A1,1),RIGHT(A1,2),0),IF(LEN(A1)=4,TIME(LEFT(A1,2),RIGHT(A1,2),0),A1))

    Remember to format cell to a time format.

    Example:

    743 = 7:43 AM

    1630 = 4:30 PM

    Will also accommodate for entering time from the computers clock by pressing,
    ( Ctrl + Shift + ; ), then Enter.

    Matt

+ 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