In data tables, JMP can accept the input of date-time values in one format (the input format), store them internally as the number of seconds since the base date, and display them in a different date-time format. The Informat() and Format() functions give you this control.
•
|
Informat() takes a string date-time value, defines the date format used in that string, and returns the date in ddMonyyyy format.
|
Informat( "19May2011 11:37:52 AM", "ddMonyyyy h:m:s" );
19May2011:11:37:52
•
|
Format() takes the number of seconds since the base date (or a date-time function that returns that number) and returns the date in the specified format.
|
Format( 3388649872, "ddMonyyyy h:m:s" );
"19May2011 11:37:52 AM"
Format( Today(), "ddMonyyyy h:m:s" );
"19May2011 11:37:52 AM"
Suppose that you are entering dates into a column using the d/m/y h:m format, but you want to see the dates in the m/d/y format. The Informat() function defines the input format, and the Format() function defines the display format. For example,
New Table( "Widget Assembly",
Add Rows( 1 ),
New Column( "Date",
Numeric,
"Continuous",
Format( "m/d/y" ),
Informat( "d/m/y h:m" ),
Set Values( [3126917100] )
)
);
The Format() and Informat() values are shown in the data table’s column properties (Example of Date-Time Display and Input Values). Note that when you click in the cell to edit it, the date-time value appears in the input format. When you edit the value, or add a new value, the format specified in the data table column Format list is used to display the value.
•
|
In a script that converts a column from character to numeric, specify Format() and Informat() to prevent missing values. See Convert Character Dates to Numeric Dates in Common Tasks for details.
|
•
|
The date-separator character on your computer might differ from the forward slash (/) character shown in this book.
|
Date-Time Formats describes the formats used as arguments in date-time functions or as data table formats. You can also use the formats for the format argument to a Format message to a data column. See Set or Get Formats in Data Tables.
For descriptions of specific date-time functions, see Date and Time Functions in the JSL Syntax Reference.