WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Excel Time Format

 Keywords: Time Format Excel Hours Minutes Date Decimal Number h:mm

Time Format

Excel stores all dates as integers and all times as decimal fractions. With this system, Excel can add, subtract, or compare dates and times just like any other numbers, and all dates are manipulated by using this system. In this system, the serial number 1 represents 1/1/1900 12:00:00 a.m. Times are stored as decimal numbers between .0 and .99999, where .0 is 00:00:00 and .99999 is 23:59:59. The date integers and time decimal fractions can be combined to create numbers that have a decimal and an integer portion. For example, the number 32331.06 represents the date and time 7/7/1988 1:26:24 a.m.

To convert hours from decimal number to the standard time format (hours : minutes : seconds) use the TEXT function. The code might look something like this:

; Reading & Displaying Time Values From Excel
format = XLObject.Cells(98,1).NumberFormat ; determines the format of the cell in Excel
replayTime = XLObject.Cells(98,1).Value ; read the cell
replayTime = XLObject.TEXT(replayTime, format); format cell for display, using previously determined format
Message("Time",replayTime)

Article ID:   W18108
Filename:   Excel Time Format.txt
File Created: 2011:01:24:10:36:50
Last Updated: 2011:01:24:10:36:50