As with Today(), the Date DMY() and Date MDY() functions also return month, day, and year arguments as seconds. For example, if it were 12:00:00 a.m. on May 19, 2011, all of the following statements would return the same value:
The As Date() function takes the number of seconds and displays it as a date or duration.
a string, for example "Thursday, May 19, 2011"
Date-Time Functions shows functions that convert seconds into date-time values and date-time values into seconds.
Returns a string representation for the date supplied. The format is based on your computer’s regional setting. So for the English (United States) locale, the date is formatted like "02/29/2004". Even if you are running JMP in English with a different locale, the locale format is applied.
As Date(expression)
Date DMY(day, month, year)
Date MDY(month, day, year)
Day(date)
Format(date, "format")
Returns the value in the format specified in the second argument. Most typically used for formatting datetime values from a number of seconds to a formatted date. Format choices are those shown in the Column Info dialog box. Also see How JMP Interprets Two-Digit Years.
Hour(datetime)
These functions return the number of seconds per n minutes, hours, days, weeks, or years. Divide by these functions to express an interval in seconds as an interval in other units.
Returns a string representation for the specified date. The format is based on your computer’s regional setting. So for the English (United States) locale, the date is formatted like "Sunday, February 29, 2004". Even if you are running JMP in English with a different locale, the locale format is applied.
MDYHMS(date)
Returns a string representation for the date supplied, formatted like "2/29/2004 00:02:20 AM".
Minute(date-time)
Month(date)
Num(date-time)
InFormat(string, "format")
Parse Date(string, "format")
Parses a string of a given format and returns datetime value expressed as if surrounded by As Date(), returning the date in ddMonyyyy format.
Second(date-time)
Returns a string representation for the date supplied, in the format mm/dd/yyyy, regardless of locale (for example, "02/29/2004").
Week Of Year(date, <rule_n>)
Year(date)
For example, if today is May 19, 2011 and the time is 11:37:52 AM, Today() returns the number of seconds, and the functions that follow show that number of seconds since the base time in different date-time formats:
Note: Long Date() and Abbrev Date() values are formatted according to your computer’s regional settings.
You can extract parts of date values using the functions Month(), Day(), Year(), Day Of Week(), Day Of Year(), Week Of Year(), Time Of Day, Hour(), Minute(), and Second(), which all return integers. If today is May 24th, 2011, each of the following examples returns the 144th day of the year:
A data table column named Date contains date-time values that are formatted as "m/d/y". You want to create a column that shows only the time. In the following script, the second column’s formula extracts the time of day from the Date value in the first column.
Example of Extracting the Time shows the result. Note that the time of day does not appear in the Date column, because the Format function applies the “m/d/y” format.
Example of Extracting the Time
Week of Year() returns the week of the year as a date-time value. Three rules determine when the first week of the year begins.
The Date column in your data table shows when a customer uses his credit card to buy gas. You want to know how many days elapse between purchases. The following script creates a Days elapsed column. The formula in that column subtracts the Date value in the current row from that of the previous row.
Example of Calculating Date-Time Values
The In Minutes, In Hours, In Days, In Weeks, and In Years functions are used to express time intervals in units rather than seconds. Each of these functions returns the number of seconds associated with a particular period of time. For example, the following expression returns the number of weeks between now and July 4, 2012.
When the argument for the interval function is empty, JMP counts by 1. You can enter another number to change the count. For example, In Years(10) converts the interval to decades. The following expression returns the number of decades between now and December 31, 2037.
How JMP Interprets Two-Digit Years explains how JMP interprets two-digit years.
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");
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.
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,
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.
Example of Date-Time Display and Input Values
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.