How-to
Convert Ignition historian CSV timestamps in Excel
Short answer
The 13-digit column is epoch milliseconds counted from 1970-01-01 00:00:00 UTC: convert it with =A2/86400000+DATE(1970,1,1) and a custom format of yyyy-mm-dd hh:mm:ss.000. For a data-match audit, script an as-stored tag history query instead of exporting from the chart, and compare both sides in UTC.
On this page
- What is the 13-digit number in the CSV?
- How do I convert the timestamp to a date in Excel?
- How do I verify the conversion against a known event?
- Which time zone is the converted column in?
- Why does the CSV have more rows than we collected?
- How do I export exactly the stored samples?
- How do I prove both databases match?
- Questions asked
The 13-digit column in that CSV is epoch milliseconds, which is how the tag historian stores every t_stamp. In Excel, =A2/86400000+DATE(1970,1,1) turns it into a UTC date-time serial, and a custom format shows the milliseconds. The tag data is correct; only the display needs converting. For the audit behind the question — proving the historian and a secondary database agree — convert both sides to UTC, but do not export from the chart: charts interpolate. Script an as-stored query and compare values at time instead.
What is the 13-digit number in the CSV? #
It is epoch milliseconds: the count of milliseconds elapsed since 1970-01-01 00:00:00 UTC, which is how the tag historian stores every timestamp. A March 2025 value sits near 1.74 trillion milliseconds past that origin, which is why the CSV shows a 13-digit integer rather than a date.
The value is not a packed yyyymmddhhmmss string, and it is not a fault in the export. The CSV writer outputs the stored t_stamp integer as-is. Tooling built for seconds-based epoch values divides by 1000 before doing anything else; Excel works in days, so you divide by a full day of milliseconds in one step. The tag data behind the number is intact.
How do I convert the timestamp to a date in Excel? #
Divide the millisecond value by 86,400,000 — the milliseconds in one day — and add the epoch with DATE(1970,1,1); Excel then holds a UTC date-time serial. Format the column yyyy-mm-dd hh:mm:ss.000 so the millisecond digits stay visible.
- Put the raw export's timestamp column in column A with the first value in A2, and insert an empty column beside it.
- In B2, enter
=A2/86400000+DATE(1970,1,1)and fill down. - Format column B as Custom
yyyy-mm-dd hh:mm:ss.000. - If the value arrived as text — the cell left-aligned, common after a quoted CSV import — use
=VALUE(A2)/86400000+DATE(1970,1,1)to force the numeric conversion. - Write
DATE(1970,1,1), never the constant 25569. The constant is only valid in the 1900 date system; a workbook on the 1904 system shifts every result by about four years. - Round-trip a few cells back to milliseconds and confirm they equal the original integers exactly. A small mismatch means a display format truncated your view, not the stored value.
| Case | Use |
|---|---|
| Value imported as text | =VALUE(A2)/86400000+DATE(1970,1,1) |
| Large export, no helper column | Power Query: = Table.AddColumn(Source, "t_utc", each #datetime(1970,1,1,0,0,0) + #duration(0,0,0,[t_ms]/1000), type datetime) |
In the Power Query line, [t_ms] stands for whatever name your query gave the millisecond column. Keep the raw integer column after converting: the readable cell is for people, the integer is the lossless key for joining rows later.
How do I verify the conversion against a known event? #
Decode one event you can identify on the HMI — a setpoint change, a pump start — and let the arithmetic prove the column. Take 1741297277000, expected between 9:41 and 9:42 PM on 03/06/2025:
- 1741297277000 ms ÷ 1000 = 1,741,297,277 s
- 1,741,297,277 ÷ 86,400 = 20,153 days with 78,077 s left over, because 86,400 × 20,153 = 1,741,219,200
- 78,077 s = 21 h + 41 min + 17 s (75,600 + 2,460 + 17)
- DATE(1970,1,1) = serial 25569, and 25569 + 20,153 = 45,722, which is 2025-03-06
- Result: 2025-03-06 21:41:17.000 UTC
That lands inside the expected window when the reference time was itself UTC. If your decoded time differs from the expected local time by a whole number of hours — 5 hours in a UTC−5 plant — the offset is the explanation and the data is correct. Any other difference is a real timestamp problem worth chasing.
Which time zone is the converted column in? #
The raw integer is always UTC and the formula adds no offset, so the converted column is UTC; keep the comparison in UTC on both sides. A fixed local offset added in Excel is wrong by one hour on every row that crosses a daylight-saving transition.
| Where you read the time | Zone it shows |
|---|---|
| Raw CSV integer | UTC, always |
| Excel formula, no offset term | UTC |
Excel formula with offset_hours/24 |
Fixed local offset; wrong across a DST change |
| Perspective trend on screen | The zone the session renders in |
| Secondary database | Whatever its timestamp column and insert logic store |
The decision: convert the secondary database's timestamps to UTC rather than shifting the Ignition side to local time. UTC has no missing or repeated hours, so row matching never breaks at a transition. On screen, expect the Perspective trend to differ from your export by your zone offset — that is rendering, not storage.
Why does the CSV have more rows than we collected? #
Because the chart, not the historian, decided the row count: a trend asks the historian for points spread across the visible range and fills the gaps between stored values by interpolation or aggregation, and the CSV captures that chart query. The export is a drawing of the pen, not the stored records.
Each pen carries its own historian settings for return format, aggregation and sample count, and they can be set to as-stored — but stored-on-change tags then render as long flat spans, and charts need extra work to draw those well. Check before trusting any export: sort by time and look at the spacing. Evenly spaced timestamps mean interpolated or fixed-sample output; irregular spacing that tracks change events means as-stored output. A chart export at a fixed interval — what you get when exporting a historian trend CSV at one-minute intervals — is a report, not an audit source.
How do I export exactly the stored samples? #
Script a dedicated tag history query instead of using the chart export: request the exact tag paths, an explicit start and end, as-stored raw values, and quality, then deliver the file with system.perspective.download(). That returns the stored rows, not the chart's samples.
- Query tag history for the exact tag paths over an explicit window. Compute the window bounds the same way the storage keeps them, by calculating epoch milliseconds from date tags, so the boundary is unambiguous.
- Set the query's return to as-stored raw values rather than a fixed number of samples. The tag history query function's documentation names the argument that selects raw versus sampled return for your version — set that one.
- Include quality in the result so bad or stale rows can be excluded on both sides of the later comparison.
- Write the CSV text and deliver it with
system.perspective.download().
# Sketch for a Perspective button event: historyData is the dataset
# returned by your own as-stored tag history query.
from java.text import SimpleDateFormat
from java.util import TimeZone
fmt = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") # UTC, ms kept
fmt.setTimeZone(TimeZone.getTimeZone("UTC"))
rows = ["t_utc,t_ms,value"] # list of str
for r in range(historyData.rowCount):
ts = historyData.getValueAt(r, 0) # java.util.Date
rows.append("%s,%d,%s" % (fmt.format(ts), ts.getTime(),
historyData.getValueAt(r, 1)))
system.perspective.download("historian_raw_export.csv", "\n".join(rows))
Only system.perspective.download is the documented call; historyData, rows and ts are illustrative. Keep both time columns in the file — the integer is the join key, the string is for people. If the export feeds a named query instead of a script, filtering history with epoch milliseconds in a named query keeps the window on the same basis. Verify the export on a short window: the row count must equal the stored record count for that tag and window, with irregular, change-driven spacing.
How do I prove both databases match? #
Align by value at time, not by identical row timestamps: stored-on-change data and a periodically written secondary table almost never share timestamps. Look up the last Ignition value at or before each secondary row, and flag differences beyond the tag's deadband.
- Export the same window from both systems with UTC timestamps.
- Check the secondary database's timestamp resolution. If it stores whole seconds, round the Ignition side to match with
=FLOOR(A2,1000)before joining. - Sort both sides ascending by time. For each secondary row, find the last Ignition value at or before its timestamp with XLOOKUP in match mode -1 (exact or next smaller); on Excel versions without XLOOKUP, MATCH with match type 1 on the sorted column returns the row index.
- Flag rows where values differ by more than the tag's configured deadband; differences inside the deadband are expected on stored-on-change data.
- Exclude bad-quality rows from both sides, then count what remains.
The decision: zero mismatches outside the deadband is a pass; each remaining mismatch is a stored record absent or altered on one side. If instead every value differs by one consistent factor, timing is not the fault — the replication path is delivering raw values where the display shows scaled, the failure behind historian replication sending raw values to a PI server.
Questions asked
Why does Excel show 1.74E+12 instead of the timestamp?
That is a display format, not a change to the data: Excel shows large numbers in scientific notation when the column is narrow or formatted as General. Set the column to Number with zero decimals and the full 1741297277000 reappears. The stored value never changed, so the conversion formula works either way.
What does a 10-digit number in a timestamp column mean?
Ten digits means seconds, not milliseconds: 1741297277 s is the same instant as 1741297277000 ms. The historian's stored column is milliseconds, so a seconds value usually means a different writer — a middleware transform or the secondary database itself. Divide by 86,400 instead of 86,400,000, or multiply by 1000 first and keep one formula.
How do I convert an Excel date back to epoch milliseconds?
Reverse the arithmetic: =(B2-DATE(1970,1,1))*86400000. For the worked example, (45722.90366898148 − 25569) × 86,400,000 = 1,741,297,277,000, the exact original integer. Run this round trip on a few rows after any reformatting; an exact match proves the conversion and the display format are both intact.
Does converting to an Excel date lose the milliseconds?
No. One millisecond is 1/86,400,000 of a day, so at 2025 serial numbers near 45,722 resolving 1 ms takes about 13 significant digits — inside Excel's 15. What hides the milliseconds is display formatting: apply the custom format yyyy-mm-dd hh:mm:ss.000 and they reappear. Only cells formatted to whole seconds, or values pasted as rounded results, actually lose them.
The secondary database stores local time with no offset. Can I still compare?
Yes, outside the transition days. Build a helper column that subtracts your fixed offset from the secondary timestamps to get UTC, join on that, and treat the two daylight-saving changeover days as unreliable — in autumn the local clock repeats an hour, so rows in that hour can match two different instants. The durable fix is storing UTC in the secondary table.