14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 Types of Data 109<br />

Date-Time Functions and Formats<br />

Tip: For descriptions of all date-time functions and their arguments, see “Date and Time Functions” on<br />

page 591 in the “JSL Syntax Reference” appendix.<br />

Date-Time Values<br />

Date-time values are stored and calculated as the number of seconds since midnight, January 1, 1904. For<br />

example:<br />

Today(); // returns 3388649872 on May 19, 2011 at 12:00:00 AM<br />

As with Today(), the Date DMY() and Date MDY() functions also return month, day, and year<br />

arguments as seconds. For example, if it were 12:00:00 a.m. on May 19, 2011, all of the following<br />

statements would return the same value:<br />

Date DMY(19,5,2011);<br />

Date MDY(5,19,2011);<br />

Today();<br />

3388608000<br />

The As Date() function takes the number of seconds and displays it as a date.<br />

As Date(3388608000);<br />

19May2011<br />

You can use date-time values in two ways:<br />

• a literal value, for example 19May2011:10:10<br />

• a string, for example "Thursday, May 19, 2011"<br />

You can perform arithmetic with date-time literals, which use the number of seconds as the base number.<br />

As Date( 19May2011 + 1 );<br />

19May2011:00:00:01<br />

Program with Date-Time Functions<br />

Table 6.2 shows functions that convert seconds into date-time values and date-time values into seconds.<br />

Table 6.2 Date-Time Functions<br />

Function<br />

Abbrev Date(date)<br />

Explanation<br />

Returns a string representation for the date supplied. The format is based<br />

on your computer’s regional setting. So for the English (United States)<br />

locale, the date is formatted like "02/29/2004". Even if you are running<br />

JMP in English with a different locale, the locale format is applied.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!