X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=doc%2Fexpressions.texi;h=345e59669d36ad6f0cc08a8f95251e3b0760fdbc;hb=163b1639eab9b48eab64752205d75f951547b5c7;hp=c6c96dfb931d8f33e8b0c56f15b8ceb35fe61af4;hpb=35dac0a274893c6ba1d58d33a0889096eef033b4;p=pspp-builds.git diff --git a/doc/expressions.texi b/doc/expressions.texi index c6c96dfb..345e5966 100644 --- a/doc/expressions.texi +++ b/doc/expressions.texi @@ -1,4 +1,4 @@ -@node Expressions, Data Input and Output, Language, Top +@node Expressions @chapter Mathematical Expressions @cindex expressions, mathematical @cindex mathematical expressions @@ -15,14 +15,14 @@ strings or numbers as operands. With few exceptions, operands may be full-fledged expressions in themselves. @menu -* Boolean Values:: Boolean values. -* Missing Values in Expressions:: Using missing values in expressions. -* Grouping Operators:: parentheses -* Arithmetic Operators:: add sub mul div pow -* Logical Operators:: AND NOT OR -* Relational Operators:: EQ GE GT LE LT NE -* Functions:: More-sophisticated operators. -* Order of Operations:: Operator precedence. +* Boolean Values:: Boolean values +* Missing Values in Expressions:: Using missing values in expressions +* Grouping Operators:: parentheses +* Arithmetic Operators:: add sub mul div pow +* Logical Operators:: AND NOT OR +* Relational Operators:: EQ GE GT LE LT NE +* Functions:: More-sophisticated operators +* Order of Operations:: Operator precedence @end menu @node Boolean Values @@ -259,7 +259,8 @@ The sections below describe each function in detail. * Statistical Functions:: CFVAR MAX MEAN MIN SD SUM VARIANCE * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER RINDEX RPAD RTRIM STRING SUBSTR UPCASE -* Time & Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx +* Time and Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx + DATEDIFF DATESUM * Miscellaneous Functions:: LAG YRMODA VALUELABEL * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF @end menu @@ -690,7 +691,7 @@ has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value Returns @var{string}, changing lowercase letters to uppercase letters. @end deftypefn -@node Time & Date +@node Time and Date @subsection Time & Date Functions @cindex functions, time & date @cindex times @@ -701,16 +702,17 @@ For compatibility, PSPP considers dates before 15 Oct 1582 invalid. Most time and date functions will not accept earlier dates. @menu -* Time & Date Concepts:: How times & dates are defined and represented +* Time and Date Concepts:: How times & dates are defined and represented * Time Construction:: TIME.@{DAYS HMS@} * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@} * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@} * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH QUARTER SECOND TDAY TIME WEEK WKDAY YEAR@} +* Time and Date Arithmetic:: DATEDIFF DATESUM @end menu -@node Time & Date Concepts +@node Time and Date Concepts @subsubsection How times & dates are defined and represented @cindex time, concepts @@ -741,27 +743,6 @@ given below correspond with the numeric PSPP dates given: 24 Aug 1995 13,028,601,600 @end example -@cindex time, mathematical properties of -@cindex mathematics, applied to times & dates -@cindex dates, mathematical properties of -@noindent -Ordinary arithmetic operations on dates and times often produce -sensible results. Adding a time to, or subtracting one from, a date -produces a new date that much earlier or later. The difference of two -dates yields the time between those dates. Adding two times produces -the combined time. Multiplying a time by a scalar produces a time -that many times longer. Since times and dates are just numbers, the -ordinary addition and subtraction operators are employed for these -purposes. - -Adding two dates does not produce a useful result. - -As the table shows, dates and times may have very large values. Thus, -it is not a good idea to take powers of these values; also, the -accuracy of some procedures may be affected. If necessary, convert -times or dates in seconds to some other unit, like days or years, -before performing analysis. - @node Time Construction @subsubsection Functions that Produce Times @cindex times, constructing @@ -1020,6 +1001,68 @@ Returns the year (as an integer 1582 or greater) corresponding to @var{date}. @end deftypefn +@node Time and Date Arithmetic +@subsubsection Time and Date Arithmetic + +@cindex time, mathematical properties of +@cindex mathematics, applied to times & dates +@cindex dates, mathematical properties of +@noindent +Ordinary arithmetic operations on dates and times often produce +sensible results. Adding a time to, or subtracting one from, a date +produces a new date that much earlier or later. The difference of two +dates yields the time between those dates. Adding two times produces +the combined time. Multiplying a time by a scalar produces a time +that many times longer. Since times and dates are just numbers, the +ordinary addition and subtraction operators are employed for these +purposes. + +Adding two dates does not produce a useful result. + +Dates and times may have very large values. Thus, +it is not a good idea to take powers of these values; also, the +accuracy of some procedures may be affected. If necessary, convert +times or dates in seconds to some other unit, like days or years, +before performing analysis. + +PSPP supplies a few functions for date arithmetic: + +@deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit}) +Returns the span of time from @var{date1} to @var{date2} in terms of +@var{unit}, which must be a quoted string, one of @samp{years}, +@samp{quarters}, @samp{months}, @samp{weeks}, @samp{days}, +@samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an +integer, truncated toward zero. + +One year is considered to span from a given date to the same month, +day, and time of day the next year. Thus, from Jan.@tie{}1 of one +year to Jan.@tie{}1 the next year is considered to be a full year, but +Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not. +Similarly, one month spans from a given day of the month to the same +day of the following month. Thus, there is never a full month from +Jan.@tie{}31 of a given year to any day in the following February. +@end deftypefn + +@deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}]) +Returns @var{date} advanced by the given @var{quantity} of the +specified @var{unit}, which must be one of the strings @samp{years}, +@samp{quarters}, @samp{months}, @samp{weeks}, @samp{days}, +@samp{hours}, @samp{minutes}, and @samp{seconds}. + +When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months}, +only the integer part of @var{quantity} is considered. Adding one of +these units can cause the day of the month to exceed the number of +days in the month. In this case, the @var{method} comes into +play: if it is omitted or specified as @samp{closest} (as a quoted +string), then the resulting day is the last day of the month; +otherwise, if it is specified as @samp{rollover}, then the extra days +roll over into the following month. + +When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours}, +@samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded +to an integer and @var{method}, if specified, is ignored. +@end deftypefn + @node Miscellaneous Functions @subsection Miscellaneous Functions @cindex functions, miscellaneous @@ -1473,4 +1516,3 @@ subtraction. @item @code{AND NOT OR} @end enumerate -@setfilename ignored