I am running a simulation (time length: 100seconds) and the results are exported to csv containing two columns. The first one is “Time” in seconds. It contains decimal numbers. The simulation step is variable. I need to convert the decimal numbers to hh:mm:ss format.

Changing the cells’ format from Number to Time in Excel is not the solution,as the simulation step is lost.

```
0 00:00:00
0,02 00:28:48 WRONG
0,04 00:57:36 WRONG
0,066 01:35:02 WRONG
0,0998 02:23:43 WRONG
0,14374 03:26:59 WRONG
0,200862 04:49:14 WRONG
0,2751206 06:36:10 WRONG
0,37165678 08:55:11 WRONG
0,497153814 11:55:54 WRONG
```

I expect the format `HH:MM:SS`

to keep the step between two simulation instants

```
0 00:00:00
0,02 00:00:00
0,04 00:00:00
........
1,007964 00:00:01
1,090020 00:00:01
......
100 00:01:40
```

Excel stores Date/Times as a Double – the Integer portion is the number of Days since 1899-12-31 – so `1`

becomes `1900-01-01`

, and `60`

becomes `1900-02-29`

, et cetera. The Decimal portion is the Time, as a **fraction of a whole day** – `0.5`

is **12 noon**.

As such, a value of `0.1`

is `2 hours, 24 minutes`

, and **not** `100 milliseconds`

This means that your code is giving exactly the right Output for what you have written, but not for what you *wanted* to write.

What you **actually** seem to want is the `TIME`

function – which accepts Hours, Minutes and Seconds, and outputs a Time value like so:

```
=TIME(01, 23, 45)
1:23 AM
=TEXT(TIME(01, 23, 45), "hh:mm:ss")
01:23:45
```

The `DATE`

and `TIME`

functions also “overflow”. That is to say, `=TIME(0, 0, 65)`

is the same as writing `=TIME(0, 1, 5)`

, both give `1 minute, 5 seconds`

.

They also “*under*flow”, so `TIME(0, 2, -55)`

will give `1 minute, 5 seconds`

as well (and `=DATE(1900,3,0)`

is `1900-02-29`

while `=DATE(1901,3,0)`

is `1901-02-28`

)

### Answer：

**Use the Formula:**

`=TIME(0,0,SUBSTITUTE(E12,",","."))`

if the format is using , instead of . use function. `=TIME(0,0,E12)`

Change the cell reference accordingly.

**Result:**

Tags: excelexcel, time