periods()

描述:

按照指定时间间隔获取日期时间序列。

语法:

periods(s,e,i)

备注:

获取从se(包括端点)每间隔i的日期时间值构成的序列。

参数:

s

日期时间变量。

e

日期时间变量。

i

整数,间隔时间,缺省单位为日,缺省为1

选项:

@y

i的单位为年。

@q

i 的单位为季度。

@m

i 的单位为月。

@t

i 的单位为旬。

@s

i 的单位为秒。

@x

不包含后端点。

@e

@x组合使用,如果e正好在间隔点上则保留。

@o

不调整。缺省情况会调整至时间单位的最初点,@t时必须被调整。

返回值:

序列

示例:

 

A

 

1

2000-08-10 12:00:00

 

2

=periods@y(A1,now(),1)

以年为间隔单位。

3

=periods@yo(A1,now(),1)

不调整。缺省情况会调整至时间单位的最初点,@t时必须被调整。

4

=periods@q(A1,now(),1)

以季度为间隔单位。

5

=periods@m(A1,now(),1)

以月为间隔单位。

6

=periods@s(A1,now(),7)

以秒为间隔单位。

7

=now()

 

8

=pdate@m(A7)

本月的起始日期。

9

=pdate@me(A7)

本月的结束日期。

10

=elapse(A8,6-day@w(A8))

获得第一个星期五。

11

=periods@x(A10,A9,7)

获得星期五序列。

12

=A11(2)

获取第二个星期五。

13

=A11.m(-1)

获取最后一个星期五。

14

=A11.len()

共几个星期五。

  使用@e选项:

 

A

 

1

2020-08-10 12:00:00

 

2

2025-01-01 00:00:00

 

3

=periods@y(A1,A2,1)

使用@y选项,序列成员间隔单位为年:

4

=periods@xy(A1,A2,1)

使用@x选项,不包含后端点:

5

=periods@exy(A1,A2,1)

使用@ex选项,如果e正好在间隔点上则保留: