Troubleshooting
Why historian CSV timestamps show only the date in Excel
Short answer
The CSV is not the problem: the export wrote the complete timestamp, and Excel's automatic type detection plus a date-only cell format hide the time. Read the raw file in a text editor to confirm the characters are there, then apply a year-month-day hour-minute-second custom format or import the timestamp column as text. Change the query only when the raw file itself lacks the time.
On this page
The export did not lose the time. A historian CSV export carries the complete timestamp characters, and the damage happens on open: the spreadsheet's automatic type detection converts the field into a date-time serial number, then a date-only column format hides the fraction of a day that holds the hours, minutes and seconds. Prove it by reading the raw file in a text editor, then fix the cell format or the import column type. Change the query or tag configuration only when the raw file itself lacks the time.
Read the raw CSV before touching the spreadsheet #
A CSV file stores field text and delimiters and nothing else: no cell formats, no column widths, no display choices. The program that opens the file decides how each field renders, which is why the same export can look different on two PCs. Check the characters the file actually contains:
- Copy the export and open the copy in a plain text editor. Opening it by double-click shows you the spreadsheet's interpretation, not the file, and saving from a spreadsheet rewrites fields in that program's image and destroys the evidence.
- Find the timestamp column, named t_stamp in an Ignition historian export.
- Pick one record you can identify from the trend and read the entire field, fractional seconds included. An illustrative row reads
2024-03-15 14:30:00,300.5,41.2: timestamp first, then the logged values. - Compare those characters with the same row as the spreadsheet shows it.
Decision: full date and time in the file means the query and the export did their job, and everything after this point is display formatting. A bare date, an integer count, or a string with the time stripped means the loss is upstream, so go to the last section.
How the spreadsheet hides the time inside a correct value #
On open, type detection recognizes the field as a date-time and stores it as one serial number: whole days in the integer part, time of day as a fraction of one day. The characters and the cell contents stop being the same thing at that moment.
Worked example for the row 2024-03-15 14:30:00:
- Day count: the serial for 2024-01-01 is 45,292 (Excel counts days from its 1899-12-30 day zero). 2024 is a leap year, so March 15 is day 75 of the year: 31 + 29 + 15. That is 74 days after 1 January, and 45,292 + 74 = 45,366.
- Time fraction: 14 h × 3600 s/h = 50,400 s, plus 30 min × 60 s/min = 1800 s, for 52,200 s. One day is 86,400 s, so 52,200 ÷ 86,400 = 0.604167 of a day, rounded to six decimals.
- Stored value: 45366.604167. A date-only format renders 2024-03-15 and hides 0.604167. The time is still in the number, which is why selecting the cell shows the full value while the column does not.
Decision: the workbook holds everything the export sent. Widening the column only cures the #### width warning; it cannot make a date-only format print a fraction.
The three fixes and when to use each #
| Route | Where it is set | Column then shows | Trade-off |
|---|---|---|---|
| Custom cell format | The cell's number format, custom code yyyy-mm-dd hh:mm:ss |
2024-03-15 14:30:00 | Keeps a real date-time value, so sorting, filtering and time subtraction still work |
| Import the column as text | Data tab, Get Data, From File, From Text/CSV; set the timestamp column's type to Text in the preview | The exact exported characters, fractional seconds included | No date arithmetic; a year-first pattern keeps text sorting chronological |
| Export a workbook instead of CSV | The platform's Excel export tools beside the CSV export | Whatever the export applies, which still needs checking | A workbook carries cell formats where CSV cannot; built-in exports rarely pick a useful one |
Excel's date codes ignore case, so the Java-style spelling yyyy-MM-dd HH:mm:ss also displays correctly in a custom format. The trap is letter position: Excel reads m as the month number unless it stands directly between the hour and second codes, so a reordered pattern such as yyyy-MM-dd mm:ss turns every minute into a month. For the text route in older Excel builds, the legacy Text Import Wizard, enabled from Excel's options in its Data section, opens when a text file opens and offers the same per-column control.
Decision: use the custom format for anything you trend, sort or subtract; import as text when an audit needs the characters exactly as exported; choose a workbook export when the spreadsheet is the file's main consumer, then still verify the timestamp column's format before sending it on.
When the time is missing before the file exists #
If the text editor shows the time already gone, work the chain in order and stop where the characters come back:
- Inspect the dataset the history query returns before any export step. In Ignition that dataset comes from system.tag.queryTagHistory; read its timestamp column values directly.
- Look for a formatting step between query and file: a script or binding that applies a date pattern to the dataset. A year-month-day-only pattern strips the time at the source, and a pattern using the 12-hour hour code where the 24-hour one belongs rewrites 14:30:00 as 02:30:00, splitting the afternoon into two look-alike halves. In Java-style patterns, HH is the 24-hour code and hh the 12-hour one; the same pattern family governs timestamp formatting in plant-floor scripting tools such as formatting dates and timestamps in OptoScript and Node-RED.
- Only then question acquisition. Raw values that are complete but shifted by whole hours belong to the UTC-offset family of faults: the UTC offset check when a historian shows a real value hours off covers the diagnosis, and the walkthrough on converting Ignition historian CSV timestamps in Excel covers offsets already baked into an export. Timestamps that carry the station's current time instead of the controller's are a clock-source problem, as in the article on historian showing current time for backdated PLC data.
A display-only symptom never justifies touching tag history settings such as deadband or maximum storage interval; those decide when a record is created, not how a spreadsheet renders the timestamp field.
Decision: fix the step that writes the characters, re-export one known window, and re-read the raw file before opening the spreadsheet again.
Questions asked
Will the same CSV look different when another PC opens it?
It can. When a CSV opens, Excel applies its own automatic type detection and default formats, which follow the regional settings of that PC. Two stations can open one file and show different displays while the characters in the file never change. That is why the raw-file check is the evidence that matters, and why an explicit format or a fixed import beats trusting whatever a given workstation happens to show.
Which custom format shows a 24-hour timestamp in Excel?
Use yyyy-mm-dd hh:mm:ss. Excel's date codes ignore case, so the Java-style spelling yyyy-MM-dd HH:mm:ss displays the same result: an hour code with no AM or PM marker means a 24-hour clock. Adding AM or PM to the code switches that cell to a 12-hour display, which is the first thing to check when afternoon rows show times between 01 and 12.
Does Excel keep the fractional seconds a historian exports?
Not reliably as a date-time value. Excel stores numbers to about 15 significant digits, and a modern serial date spends five of them on the day count, which leaves the fraction little precision for sub-second components and can round them away. When an audit needs the exact exported characters, import the timestamp column as text so the file's digits survive untouched.
Should tag logging settings be changed to fix the missing time?
No. Tag history settings such as deadband and maximum storage interval decide when a record is created; they have no effect on how a spreadsheet renders the timestamp field. A date-only display is a presentation fault with a complete value behind it. Reserve configuration changes for a raw file that genuinely lacks records or time components, which the text-editor check will show.