Date-Time Functions shows functions that convert seconds into date-time values and date-time values into seconds.
Abbrev Date(date)
|
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)
|
As Date( 50000 );
|
Returns the specified date expressed as the number of seconds since midnight, 1 January 1904. For example, the second Leap Day of the third millennium is DateDMY(29,2,2004), which returns 3160857600.
|
|
Returns the specified date expressed as the number of seconds since midnight, 1 January 1904. For example, the second Leap Day of the third millennium is DateMDY(2,29,2004), which returns 3160857600.
|
|
Day Of Week(date)
|
Returns an integer representation for the day of the week of the date supplied. Weeks are Sunday–Saturday.
|
Day Of Year(date)
|
|
Day(date)
|
|
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 表 6.3.
|
|
Hour(datetime)
|
Returns an integer representation for the hour part of the date-time value supplied.
|
In Days(n)
|
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.
|
Long Date(date)
|
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)
|
|
Minute(date-time)
|
Returns an integer representation for the minute part of the date-time value supplied.
|
Month(date)
|
Returns an integer representation for the month of the date supplied.
|
Num(date-time)
|
Returns an integer representation for the date-time value supplied.
|
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 an integer representation for the second part of the date-time value supplied.
|
Short Date(date)
|
Returns a string representation for the date supplied, in the format mm/dd/yyyy, regardless of locale (for example, "02/29/2004").
|
Time Of Day(date)
|
Returns an integer representation for the time of day of the date-time supplied.
|
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:
Today()
Short Date( Today() );
Long Date( Today() );
Abbrev Date( Today() );
MDYHMS( Today() );
Long Date( 3388649872 );
Long Date( 19May2011 );
注意: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:
Day of Year( Today() );
Day of Year( 24May2011 );
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.
New Table( "Assembly Tests",
Add Rows( 1 ),
Set Values( [3389083557] )
图 6.1 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.
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.
New Table( "Gas Purchases",
Add Rows( 3 ),
Set Values( [3392323200 3393532800 3394828800] )
图 6.2 shows the result.
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.
Long Date( 25May11 );
Long Date( 25May1911 );
How JMP Interprets Two-Digit Years explains how JMP interprets two-digit years.