You are here:

Excel/formatting to show just time

Advertisement


Question
timesheet
timesheet  
QUESTION: Hi there, wondering if you can help me. I am designing a time sheet (for the first time) for some payroll hours to be recorded

I want the Manager in charge (not finance/computer literate to a high degree) to be able to type in start times and end times of a shift

when I select time on a cell which has 8.00 in it, it isn't bringing back 08:00 it is pulling in 08/01/1900  00:00:00 instead

can I format it so that if they enter 8 it gives 08:00, if they enter 11:30 or 22:00 it stays as time and can calculate length of shift in minutes/hrs ?

attached is image of my timesheet

thank you

ANSWER: sara,

Excel has built in behavior for how it reacts to specific number entry formats for cells formatted for date/time.  

If you want to overcome that you have to write VBA code to handle the entry and do the conversion.

Chip Pearson has written routines to do this.  He is a link to his page:

http://www.cpearson.com/excel/DateTimeEntry.htm

It seems to me it would be easier if you tell/train the person they have to use 8:00  or 8:15  or 16:45 as examples.  

--
Regards,
Tom Ogilvy


---------- FOLLOW-UP ----------

QUESTION: Thank you Tom - that was a quick response!

Yes I am definitely going to train them to enter 08:00 08:15 and so on however even when I enter these myself it is bringing through 08/01/1900 00:00:00 in the cell

I would like them to be able to enter 08:15 and it stay as 08:15 without having to enter a date and time

Answer
Sara,

If you format a cell as Date or time or Date and time, then the entry should be stored as a date serial number.  The data serial number in Windows Excel defaults to a base of 1900 and dates and times are stored as the elapsed number of days from this base date.   

if you go into a cell formatted a general and enter 0.25, then format that cell as time, the time should appear as  6:00 AM or 6:00 depending on the format you choose.  The .25 represents 1/4 of a day or 6 hours.   If you formatted the cell as  dd/mm/yyyy h:mm AM/PM, then that same cell which as .25 in it would appear as 00/01/1900 6:00 AM   meaning the zeroth day of January 1900.  So times and dates are a single type of data - not two separate types.   You determine how to use it by the way you format the cell.

go to a cell formatted as general and enter =Now()

for me Excel formats the cell as m/d/yyyy h:mm  and it displays as   6/9/2016 7:41   

if you copy and then paste values on that cell, the =Now() will be replaced with a hard coded date.  While it continues to look the same, when I select the cell and look in the formula bar it displays  6/9/2016  7:41:27 AM

Now I format that cell a general and it displays  42530.32045  and in the formula bar it shows that the actual number stored is:  42530.320453588

the 42430  are the elapsed number of days from the base date of midnight 31 Dec 1899 (just before turning into 1 Jan 1900).  

So enter 08:00 in a cell where you get 08/01/1900 00:00:00  and I would guess you will see the number 8 rather than 0.333333333333333 which is what I see when I enter 8:00 and then format as general.   

So the question becomes why this is happening.  I suspect that you have not defined colon (":") as the time separator in Windows.   

If you can go into the visual basic editor (VBE) in Excel (Alt+F11), then in the view menu of the VBE select immediate window to make the immediate window visible at the bottom of the VBE.  Click in the immediate window and type  

? Application.International(xlTimeSeparator)  and hit enter

for me it returns colon
? application.International(xlTimeSeparator)
:

(you can get back to the Excel worksheet by doing Alt+F11)

I can only guess that is not the case for you and that is why excel is not seeing 8:00 as a time value.  

You can change the time separator by going to regional settings in Windows.

go to the control panel in windows.  Select Region and Language.  In the resulting dialog, the first tab should show Short and Long date format and other settings.   If those formats look strange in that a colon is not used, then click on the additional button and you can change the time separator and so forth.

Excel uses these windows settings to the best of my knowledge.  I can't say i fyou have language packs installed and so forth.  Since I am in the US, I am somewhat insulated from International issues but being in the UK I would expect that to be pretty much the same for you.  If you want to send the workbook to be, I can take a look   twogilvy@msn.com

--
Regards,
Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.