OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis                     
 

4.5.2 Dates and Times in the Worksheet

As mentioned, all data in the worksheet is treated as either text or numeric. If data are left-aligned in the worksheet, they are being treated as text; if they are right-aligned, they are being treated as numeric.

Date-time text vs numeric.png

It is important to understand these things:

  • Date-time data that are left-aligned in the worksheet are being treated as text, despite appearing to be date-time data.
  • Properly formatted date-time data will be right-aligned and are stored internally as numeric data of type Double(8) -- 64-bit, double-precision numbers. Any math operations on date-time data are performed using the internally-stored double-precision numbers.

Origin's Date-Time System

Origin interprets dates based on the Gregorian Calendar and supports a date range of 1/1/0100 to 12/31/9999. Origin's internal system for date-time is based on the astronomical Julian Day, which defines January 1, -4712 (January 1, 4713 BCE), 12 hours Greenwich Mean Time as "time zero" (t0). Origin's default time-keeping system differs in employing a 12 hour offset (see Origin's Default System: Adjusted Julian Date).

Beginning with Origin 2019, Origin gets two new date-time systems that use alternate "time zero" points. One is a "true Julian Date" system that drops the default system's 12 hour offset. The other is a "2018" system for those who deal in fractional seconds and need greater precision than the default system can provide. For more information, see Alternate Date-Time Systems in Origin.

Formatting Date and Time Data

Unless you are making use of Origin's available mechanisms for parsing date-time data (e.g. an import filter) you will likely find that your date-time data are treated as text during import. At this point, the procedure for applying proper date-time formatting to imported worksheet data goes something like this:

  1. Open the Column Properties dialog box by (a) double-clicking on the column heading of your date-time data column, (b) selecting the column then right-clicking and choosing Properties or from the menu choosing Format: Column.
  2. In the Properties dialog, click the Properties tab. Under Options, set the Format to Date or Time (Date formats can handle a time component; Time formats handle only days (IRIG), hours, minutes, seconds and fractional seconds.
  3. Click the Display drop-down list and try to match your data to one of the listed date or time formats. For guidance, see Origin's Date and Time Format Specifiers, listed below.
  4. If none of the built-in formats match the format of your date-time data, look toward the bottom of the list for two custom date formats Global Custom 1 or Global Custom 2 and try to find a match there.
  5. If you fail to find a suitable match in the built-in or global custom Date or Time formats, set Display = Custom Display. Look for a matching custom date-time format (there is a pre-populated list containing some common custom formats); or directly enter a custom date-time string in the Custom Display box using Origin's Date and Time Format specifiers.


Note that you could preset the column to display date-time and then directly enter your date-time data using the keyboard. While there is some advantage in doing this -- for instance, if you set Format = Date and Display = the topmost built-in format (e.g. "10/2/2018") and begin direct keyboard entry, Origin will correctly parse "10/02/2018", "Oct 2, 2018" and "10-2-18" and display these in the chosen format -- most will find themselves having imported a data file and wanting to display the left-aligned (text) date-time data correctly as right-aligned, numeric data with a specific date-time display format. To see how a typical import of date-time data might be done, see the tutorial Import Time Data.

When you define a Custom Display format in the Column Properties dialog box, the custom format is added to the Custom Date Format list in the ASCII Import (impASC) dialog box. Save this file structure option as part of your Theme and you can easily import new files without having to recreate your original settings.

Date & Time formats and their underlying numeric values

Once you have properly formatted your date-time string as date-time data (it is right-aligned in the worksheet cell indicating that it is recognized as numeric), you can freely switch between any of the available date-time display formats without any loss of precision. Recall that date-time values are stored internally as numerics of type Double(8) and that what appears in the worksheet is merely a representation of that underlying numeric value. Changing the display format from 9/19/2018 HH:mm:ss to Wed and back to 9/19/2018 HH:mm:ss, does not affect the underlying numeric value.

The following image was made by filling all worksheet columns with the same (numeric) Julian Day value, then setting a different formatting option for each column, using the Column Properties Display list.

Formatting date time worksheet.png

Origin's Date and Time Format Specifiers

The following table lists Origin's supported date-time format specifiers. Use these to interpret available built-in formats or to construct Custom Display formats.

To signify... ... use these specifiers

Month

  • M = number of month (for example, January = 1). Separators (enclosed in single quotes) must follow this element.
  • MM = 2 digit number of month (for example, January = 01).
  • MMM = three letter abbreviation (for example, Jan).
  • MMMM = full month name (for example, January). Separators (enclosed in single quotes) must follow this element.

Day

  • d = day of month (for example, 1). Separators (enclosed in single quotes) must follow this element.
  • dd = two digit day of the month (for example, 01).
  • ddd = three letter abbreviation of day (for example, Mon).
  • dddd = full day name (for example, Monday). Separators (enclosed in single quotes) must follow this element.

Year

  • y = last 1 or 2 digits of year (for example, 1901 = 1). Separators (enclosed in single quotes) must follow this element.
  • yy = last 2 digits of year (for example, 1901 = 01).
  • yyyy = full year (for example, 1901 = 1901).

Hour

  • h = hours with no leading zero for single-digit hours; 12-hour clock. Separators (enclosed in single quotes) must follow this element.
  • hh = hours with leading zero for single-digit hours; 12-hour clock.

Hour

  • H = hours with no leading zero for single-digit hours; 24-hour clock. Separators (enclosed in single quotes) must follow this element.
  • HH = hours with leading zero for single-digit hours; 24-hour clock

Minute

  • m = minutes with no leading zero for single-digit minutes. Separators (enclosed in single quotes) must follow this element.
  • mm = minutes with leading zero for single-digit minutes.

Seconds

  • s = seconds with no leading zero for single-digit minutes. Separators (enclosed in single quotes) must follow this element.
  • ss = seconds with leading zero for single-digit seconds.
Decimal after seconds
  • # = one digit after the decimal point for seconds.
  • ## = two digits after the decimal point for seconds.
  • ### = three digits after the decimal point for seconds.
  • #### = four digits after the decimal point for seconds.

Note: By default, date-time in Origin (Format = Date, but data include a time component) are stored internally as Julian-day (double) values where the integer part of the value is days and the fractional part is seconds. In this system, assuming contemporary dates, resolution is limited to 0.0001 seconds when rounded at the fourth decimal digit.

Beginning with Origin 2019, you can choose a "2018" system in which "time zero" is January 1, 2018 at 00:00. In this system, the integer part is smaller allowing for more resolution for the fractional part. In this "2018" system, measurements to 10-8 seconds can be supported.

Time marker

  • t = one character time marker string, such as A or P.
  • tt = multi-character time marker string, such as AM or PM.

Custom Date and Time Formats

Places where you can define custom date and time formats

  • Define up to two custom date-time formats in Tools: Options. These two custom formats will show near the bottom of the Column Properties Display list and are labeled as (Global Custom 1) and (Global Custom 2).
  • Define any number of date formats directly in the Custom Display box that shows when you set Display = Custom Display on the Properties Tab of the Column Properties dialog box.
  • Define custom date formats on the Data Columns Page of the Import Wizard dialog.

Custom date and time formats defined in Column Properties or in the Import Wizard will be saved in the project. In contrast, the two global custom date-time formats defined in Tools: Options are locked to the Origin installation on which they were defined.

Other things to note about custom date and time formats

  • Custom date strings are limited to no more than 60 characters.
  • "Sandwich" format strings such as TIME-DATE-TIME or DATE-TIME-DATE are not allowed.
  • Only the standard, regionally-defined '.' and ',' are supported as decimal point separators between seconds and fractional seconds.
  • When you define a custom date format, it will list at the top of the Custom Display drop-down list. Custom date-time formats are saved in the project file. To share the format with other users without sharing your project file, go to your User Files Folder (Help: Open Folder: User Files Folder) and look for the Origin.ini. Open the file in a text editor and find the Column Custom Format List section. Copy the format and send it to your colleague. Your colleague can paste the customized format to the Column Custom Format List section of his/her User Files Folder/Origin.ini file and resave the .ini file.

Custom Dates Examples

When the structure of date-time data in your worksheet does not match one of Origin's built-in or available custom format options, you will need to define your own custom format. As mentioned in Formatting Date and Time Data, you can use Origin's Date and Time Format Specifiers to:

  • Define a Global Custom format in Tools: Options.
  • Directly enter a custom date-time definition on the Data Columns page of the (ASCII) Import Wizard, with the option of creating an import filter file that, among other things, "remembers" your custom date-time format.
  • Directly enter a custom date-time definition in the Custom Display box in Column Properties. Note that definitions entered here are saved to the Origin.ini file and will become permanent in the Custom Display list, unless otherwise removed by editing the [Column Custom Format List] of Origin.ini.
ColProiperties custom date time formats.png

For instance, to create a custom date selection that displays the format ...

Saturday, September 5, 1998

.... you need a specifier for full day name (dddd), full month name (MMMM), day of the month (d) and full year (yyyy). You need to single-quote separators except when dealing with decimal seconds.

Hence, you would type:

dddd','MMMM' 'd','yyyy

Custom date string elements are case-sensitive (for example, "MM" is month number with leading-zeros, "mm" is minutes with leading-zeros, "Mm" is not allowed). Elements in the custom date string may be separated by any alphanumeric character not listed above. If an element does not clearly specify how many characters should be expected on input, it must be followed by a separator enclosed in single quotes. If the element is last in the format string, the separator does not have to be in single quotes. Separators will appear in the same location in the worksheet display. However, the single quotes will not be displayed. You cannot have two separators in single quotes adjacent to each other (for example, "ddd '|' '-'MMM").

When a space is enclosed in single quotes, it is used as a parser. This means that the data that is put in the cell must have the same number of characters between data values as are enclosed in the single quotes. If you want to add space to data that does not already have it, use unquoted separators in the custom date string. These spaces, however, will be used only for display purposes, not for parsing an input date-time string. See the following table for examples.

Custom Date Input Output Notes

MM dd

0416

04 16

The unquoted space was ignored by the parser. Therefore, the input was strictly according to the format.

MM' 'dd

02 12

02 12

The format expected just one space separator, but it is acceptable to have extra spaces in the string.

MM' 'dd

0212

-

A space separator was expected, so the parser failed.

IRIG Time

The IRIG (Inter-Range Instrumentation Group) time format is used in government, military, and commercial fields. The most common version of the IRIG Time Format is IRIG-B, which sends day of year (0 - 365/366), hour, minute, seconds/fractional seconds data on a 1000 Hz carrier with an update rate of one second.

Origin supports import and display of IRIG time in the worksheet, by drag-and-drop, ASCII import (File: Import ASCII) or Import Wizard (File: Import: Import Wizard). While your files with IRIG times should import as numeric data (no need to convert from text to numeric), you may want to adjust the Column Properties Display drop-down to display your data in a particular format. The following Display formats are reserved specifically for IRIG time, when Format = Time, where ...

  • DDD = 3 digit day count


with the option of displaying the following components:

  • DDD:HH - leading zero, 24 hour time
  • DDD:HH:mm - leading zero, minutes
  • DDD:HH:mm:ss - leading zero, seconds
  • DDD:HH:mm:ss.## - fractional seconds, 2 decimal places
  • DDD:HH:mm:ss:###### - fractional seconds, 6 decimal places

Origin supports custom display of IRIG time, as long as you use these format specifiers. In addition, you may display your IRIG time data in any of the standard (e.g. hh mm ss'.'##) or custom time formats built using the time format specifiers listed in the table above.

 

© OriginLab Corporation. All rights reserved.