Display milliseconds in Excel

后端 未结 4 1408
深忆病人
深忆病人 2020-12-01 05:18

I am trying to display milliseconds in an Excel macro. I have a column of integers which are timestamps in milliseconds (e.g. 28095200 is 7:48:15.200 am), and I want to mak

相关标签:
4条回答
  • 2020-12-01 05:29

    First represent the epoch of the millisecond time as a date (usually 1/1/1970), then add your millisecond time divided by the number of milliseconds in a day (86400000):

    =DATE(1970,1,1)+(A1/86400000)

    If your cell is properly formatted, you should see a human-readable date/time.

    0 讨论(0)
  • 2020-12-01 05:30

    I've discovered in Excel 2007, if the results are a Table from an embedded query, the ss.000 does not work. I can paste the query results (from SQL Server Management Studio), and format the time just fine. But when I embed the query as a Data Connection in Excel, the format always gives .000 as the milliseconds.

    0 讨论(0)
  • 2020-12-01 05:32

    Right click on Cell B1 and choose Format Cells. In Custom, put the following in the text box labeled Type:

    [h]:mm:ss.000 
    

    To set this in code, you can do something like:

    Range("A1").NumberFormat = "[h]:mm:ss.000"
    

    That should give you what you're looking for.

    NOTE: Specially formatted fields often require that the column width be wide enough for the entire contents of the formatted text. Otherwise, the text will display as ######.

    0 讨论(0)
  • 2020-12-01 05:34

    I did this in Excel 2000.

    This statement should be: ms = Round(temp - Int(temp), 3) * 1000

    You need to create a custom format for the result cell of [h]:mm:ss.000

    0 讨论(0)
提交回复
热议问题