pentaho 报表设计器中某个月的天数

days of certain month in pentaho report designer

我正在使用 Pentaho Report Designer 版本:7.0.0.0-25。

我想显示某个月的所有天数。但是月和年是参数,即月和年是动态选择的。我想显示所选月份的所有日期。 请建议我在 Pentaho 报表设计器中使用 oracle 或脚本进行查询。

分层查询有帮助。

只是设置默认日期格式;你不必这样做:

SQL> alter session set nls_date_format = 'dd.mm.yyyy';

Session altered.

这是您需要的:输入参数是

  • 月 (par_month)
  • 年 (par_year)

月份转换为两位数的值(使用LPAD函数)以便TO_DATE的格式掩码工作正常。

SQL> with test (start_date) as
  2    (select to_date(lpad(&par_month, 2, '0') || &par_year, 'mmyyyy')
  3     from dual
  4    )
  5  select start_date + level - 1 datum
  6  from test
  7  connect by level <= to_number(to_char(last_day(start_date), 'dd'));
Enter value for par_month: 2
Enter value for par_year: 2019
old   2:   (select to_date(lpad(&par_month, 2, '0') || &par_year, 'mmyyyy')
new   2:   (select to_date(lpad(2, 2, '0') || 2019, 'mmyyyy')

DATUM
----------
01.02.2019
02.02.2019
03.02.2019
04.02.2019
05.02.2019
06.02.2019
07.02.2019
08.02.2019
09.02.2019
10.02.2019
11.02.2019
12.02.2019
13.02.2019
14.02.2019
15.02.2019
16.02.2019
17.02.2019
18.02.2019
19.02.2019
20.02.2019
21.02.2019
22.02.2019
23.02.2019
24.02.2019
25.02.2019
26.02.2019
27.02.2019
28.02.2019

28 rows selected.

SQL>