Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Eviews5 / EViews5 / Docs / EViews 5 Command Ref.pdf
Скачиваний:
75
Добавлен:
23.03.2015
Размер:
5.23 Mб
Скачать

Appendix F. String and Date Function Reference

EViews provides a full library of string and date functions for use with alphanumeric and date values. Chapter 7, “Strings and Dates”, on page 119 contains a discussion of the use of strings and dates in EViews, and provides a description of the string and date functions.

The following is an alphabetical listing of the functions used when working with strings and dates in EViews.

@dateadd

Date Function

 

 

Syntax:

@dateadd(d, offset[, u])

Argument 1:

date number, d

Argument 2:

number of time units, offset

Argument 3:

time unit, u

Return:

date number

Returns the date number given by d offset by offset time units as specified by the time unit string u. If no time unit is specified, EViews will use the workfile regular frequency, if available.

Example:

Suppose that the value of d is 730088.0 (midnight, December 1, 1999). Then we can add and subtract 10 days from the date by using the functions

@dateadd(730088.0, 10, "dd")

@dateadd(730088.0, -10, "dd")

which return 730098.0 (December 11, 1999) and (730078.0) (November 21, 1999). Note that these results could have been obtained by taking the original numeric value plus or minus 10.

To add 5 weeks to the existing date, simply specify “W” or “WW” as the time unit string:

@dateadd(730088.0, 5, "ww")

returns 730123.0 (January 5, 2000).

596—Appendix F. String and Date Function Reference

@datediff

Date Function

 

 

Syntax:

@datediff(d1, d2[, u])

Argument 1:

date number, d1

Argument 2:

date number, d2

Argument 3:

time unit, u

Return:

date number

Returns the difference between two date numbers d1 and d2, measured by time units specified by the time unit string u. If no time unit is specified, EViews will use the workfile regular frequency, if available.

Example:

Suppose that date1 is 730088.0 (December 1, 1999) and date2 is 729754.0 (January 1, 1999), then,

@datediff(730088.0, 729754.0, "dd")

returns 334 for the number of days between the two dates. Note that this is result is simply the difference between the two numbers.

The following expressions calculate differences in months and weeks:

@datediff(730088.0, 729754.0, "mm")

@datediff(730088.0, 729754.0, "ww")

return 11 and 47 for the number of months and weeks between the dates.

@datefloor

Date Function

 

 

Syntax:

@datefloor(d1, u[, step])

Argument 1:

date number, d1

Argument 2:

time unit, u

Argument 3:

offset, step

Return:

date number

Finds the first possible date number associated with d1 in the given time unit u, with an optional step offset.

Example:

@datestr—597

Suppose that date1 is 730110.5 (12 noon, December 23, 1999). Then the @DATEFLOOR values

@datefloor(730110.5, "dd")

@datefloor(730110.5, "mm")

yield 730110.0 (midnight, December 23, 1999) and 730088.0 (midnight, December 1, 1999).

@datefloor(730098.5, "q")

@datefloor(730110.5, "y", 1)

returns 730027.0 (midnight, October 1, 1999), and 729754.0 (midnight, January 1, 2000).

@datepart

Date Function

 

 

Syntax:

@datepart(d1, u)

Argument 1:

date number, d1

Argument 2:

time unit, u

Return:

number

Returns a numeric part of a date number given by u, where u is a time unit string.

Example:

Consider the d1 date value 730110.5 (noon, December 23, 1999). The @DATEPART values for

@datepart(730110.5, "dd") @datepart(730110.5, "w") @datepart(730110.5, "ww") @datepart(730110.5, "mm") @datepart(730110.5, "yy")

are 23 (day of the month), 4 (week in the month), 52 (week in the year), 12 (month in the year), and 1999 (year), respectively).

@datestr

Date Function | String Function

 

 

Syntax:

@datestr(d[, fmt])

Argument 1:

date number, d

Argument 2:

date format string, fmt

Return:

string

598—Appendix F. String and Date Function Reference

Convert the numeric date value, d, into a string representation of a date, str, using the optional format string fmt.

Example:

@datestr(730088,"mm/dd/yy")

will return “12/1/99”,

@datestr(730088,"DD/mm/yyyy")

will return “01/12/1999”, and

@datestr(730088,"Month dd, yyyy")

will return “December 1, 1999”, and

@datestr(730088,"w")

will produce the string “3”, representing the weekday number for December 1, 1999. See “Dates” on page 129 of the User’s Guide for additional details on date numbers and date format strings. See also @strdate (p. 607).

@dateval

Date Function | String Function

 

 

Syntax:

@dateval(str1[, fmt])

Argument 1:

string, str1

Argument 2:

date format string, fmt

Return:

date number

Convert the string representation of a date, str, into a date number using the optional format string fmt.

Example:

@dateval("12/1/1999", "mm/dd/yyyy")

will return the date number for December 1, 1999 (730088) while

@dateval("12/1/1999", "dd/mm/yyyy")

will return the date number for January 12, 1999 (729765).

See “Dates” on page 129 of the User’s Guide for additional details on date numbers and date format strings.

Соседние файлы в папке Docs