Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen

Datetime Functions

Info

For the purpose of this reference guide: Date refers only to year, months, days (and quarters, weeks) and their combinations. Time refers to hours, minutes and seconds and their combinations. For combination of date and time we strictly use datetime term.

Tip

See the Date and time functions inherited from transformation scripting.

Date strings

The date string parameters are entered absolutely (dd.MM.yyyy, yyyy-MM-dd or according to domain settings) or relatively (time variables) by operators:

date +|- n[d|w|m|q|y]

where

  • date is date in dd.MM.yyyy or yyyy-MM-dd format, or one of actualyear, actulamonth, actualquarter, actualweek, actualday, now
  • n represents the count of:
  • d days, w weeks, m months, q quarters or y year.

Examples:

Code Block
'2011-01-01 + 1q - 2m + 1d' means Jan 1, 2011 + 1 quartal - two months + 1 day, that represents Feb 2, 2011
'actualYear + 1m + 1d' , (used on 8 Mar, 2011) means 1 Feb, 2011 + 1 month + 1 day, that represents 2 Feb, 2011 as well

Another way how to create the date strings is following:

Code Block
date(day: dd, month: MM, year: YYYY)
date(d: dd, m: MM, y: YYYY)
date(week: w, year: YYYY)
date(quarter: q, year: YYYY)

Changing datetime context

What is the datetime context? Consider following example:

 

01/2011

02/2011

03/2011

formula indicator

1000

1200

1300

Formula is evaluated for each column - in this example, in columns are values evaluated for particular months. During the evaluation of value 1000, the datetime context was 01/2011, then during the processing of value 1200, the context was 02/2011 etc.

Function

Description

Object dateAt(String dateString, { expression })

Changes the context of the evaluated expression to dateString date. Example:

Code Block
dateAt('2011-01-01', {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Object dateInterval(String from, String to, { expression })

Changes the date context of the expression and evaluates it aggregated in the specified interval from - to. Example:

Code Block
dateInterval('2011-01-01', '2011-12-31' {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Values for the indicators M_NAME_1 and M_NAME_2 are aggregated for the whole period.

Object timeAt(String timeString, { expression })

Changes the context of the evaluated expression to timeString date. Example:

Code Block
timeAt('13:33:23', {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Object timeInterval(String from, String to, { expression })

Changes the time context of the expression and evaluates it aggregated in the specified interval from - to. Example:

Code Block
timeInterval('00:00:01', '23:59:59' {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Values for the indicators M_NAME_1 and M_NAME_2 are aggregated for the whole period.

Object dateAt (String date, String period) { expression })

Changes the context of the evaluated expression to dateString date - aggregated by the defined period {DAY, D, WEEK, W, MONTH, M, YEAR, Y}.

Object dateInterval (String from, String to, String period ) { expression })

Changes the date context of the expression and evaluates it aggregated in the specified interval from - to. Aggregation by the defined period {DAY, D, WEEK, W, MONTH, M, YEAR, Y} is also performed.

Object minus(String date, period, int)

Substracts the amount of specified period (years, months, weeks, days) to the defined date value.

Code Block
minus(date(firstValue('L_DATE')), 'days', 20) //subtracts 20 days from the date value


Object minus(String time, period, int)

Adds the amount of specified period (years, months, weeks, days) to the defined date value.

Code Block
minus(time(firstValue('L_TIME')), 'minutes', 30) //subtracts 30 minutes from the time value
Object plus(String date, period, int)

Adds the amount of specified period (years, months, weeks, days) to the defined date value.

Code Block
plus(date(firstValue('L_DATE')), 'days', 20) //adds 20 days to the date value


Object plus(String time, period, int)

Adds the amount of specified period (hours, minutes, seconds) to the defined date value.

Code Block
plus(time(firstValue('L_TIME')), 'seconds', 50) //adds 50 seconds to the time value

Object timeAt (String time, String period) { expression })

Changes the context of the evaluated expression to timeString time - aggregated by the defined period {HOUR, H, MINUTE, SECOND}.

Object timeInterval (String from, String to, period) { expression })

Changes the time context of the expression and evaluates it aggregated in the specified interval from - to. Aggregation by the defined period {HOUR, H, MINUTE, SECOND} is also performed.

Object withoutDateTime() { expression })

Evaluates the expression without date time interval.

Obsolete functions

Warning

These functions may be removed in further releases

Function

Description

Object value(String dateString, String indicator)

Loads the indicator's value at specified date.

Object value(String dateString, int drill_down_level)

Loads the indicator's value at specified date aggregated for N previous levels.

Object value(String dateFrom, String dateTo, String indicator)

Loads cumulative indicator's value for specified date interval.

Object value(String dateFrom, String dateTo, String indicator, int dril_down_level)

Loads cumulative indicator's value for specified date interval aggregated for N previous levels.

Advanced functions

 

Function

Description

Number cumulateFromDate(String startDate, String indicator)

This function gradually adds the current value to the cumulated value. Example:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

cumulateFromDate('2011-01-01', 'M_NAME_1')

1000

2200

3500

Number cumulateFromTime(String startTime, String indicator)

This function gradually adds the current value to the cumulated value. Example:

Section
Column

 

00:01

00:02

00:03

M_NAME_1

1000

1200

1300

cumulateFromTime('00:01', 'M_NAME_1')

1000

2200

3500

prev(String indicatorCode)

Value of the passed indicator calculated for previous date or time value (e.g. previous month, day, hour, ...). Example:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

prev('M_NAME_1')

 

1000

1200

Number prev(String indicatorCode, int prevLevelAgg)

Value of the passed indicator calculated for previous date or time value (e.g. previous month, day, hour, ...). Parameter prevLevelAgg represents number of previous levels which should be aggregated.

Number next(String indicatorCode)

Value of the passed indicator calculated for next date or time value (e.g. previous month, day, hour, ...). Example:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

next('M_NAME_1')

1200

1300

 

Number next(String indicatorCode, int prevLevelAgg)

Value of the passed indicator calculated for next date or time value (e.g. previous month, day, hour, ...). Parameter prevLevelAgg represents number of previous levels which should be aggregated.

int daysBetween(DateTime dateFrom, DateTime dateTo)

Function calculates number of days between provided dates.

int daysBetween(DateTime dateFrom, DateTime dateTo, int[])

Function calculates number of days between provided dates and excludes selected day(s) of the week. Day of the week is referenced by number: 1 is Monday, 7 is Sunday.


Following example shows, how Saturdays and Sundays can be excluded from the calculation:

Code Block
daysBetween(date(firstValue('L_DATE_FROM'),date(firstValue('L_DATE_TO'), 6,7)


int daysBetween(LocalDate dateFrom, LocalDate dateTo)

Function calculates number of days between provided dates.

int monthsBetween(DateTime dateFrom, DateTime dateTo)

Function calculates number of months between provided dates.

int monthsBetween(LocalDate dateFrom, LocalDate dateTo)

Function calculates number of months between provided dates.

int yearsBetween(DateTime dateFrom, DateTime dateTo)

Function calculates number of years between provided dates.

int yearsBetween(LocalDate dateFrom, LocalDate dateTo)

Function calculates number of years between provided dates.

For changing the whole context of the evaluated expression, you can use following functions:

Number prev(String period, { expression })

Changes the context of the expression to desired previous date period. The value of the period parameter is one of: DAY, WEEK, MONTH, QUARTER, YEAR. Example:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

prev(MONTH) { M_NAME_1 } 

 

1000

1200

Number next(String period, { expression })

Changes the context of the expression to desired next date period. The value of the period parameter is one of: DAY, WEEK, MONTH, QUARTER, YEAR

The following example works with values, which are loaded for one year before the actual table/chart datetime entry:

Code Block
return prev(YEAR) {
  M_NAME_1 / M_NAME_2 * 100
}
Info

You may simply enter only the first letter of time unit (in case of time context changing formulas) instead of their full names (Y,Q,M,W,D), for example prev(Y){}

Nested expressions

Date and time functions can be combined (if applicable), eg.: Value of M_INDICATOR at 8th December 2010, 9:04:02AM:

Code Block
dateAt ('2010-12-08') { timeAt('09:04:02') { M_INDICATOR } }

Next Steps

Sv translation
languageja
日付機能

日時関数

Info

この参照ガイドの目的: 日付は年、月、日、(四半期、週)とその組み合わせのみを表します。時刻は時間、分、秒とその組み合わせを表します。日付と時刻の組み合わせでは厳しく日付時刻用語の使用を取り入れています。

Tip

変換スクリプトから継承している日付時刻機能を参照してください。

日付ストリング

日付ストリングパラメーターは操作者によって絶対的(dd.MM.yyyy, yyyy-MM-dd またはドメインの設定によって)にまたは相対的(時刻変数)に入力されます。

date +|- n[d|w|m|q|y]

どこ

  • date dd.MM.yyyy または yyyy-MM-dd 形式、またはactualyear, actulamonth, actualquarter, actualweek, actualday, nowのうちの一つで表された日付です。
  • nは数を表します
  • d日、w週、m月、q四半期、y

:

Code Block
'2011-01-01 + 1q - 2m + 1d' means Jan 1, 2011 + 1 quartal - two months + 1 day, that represents Feb 2, 2011
'actualYear + 1m + 1d' , (used on 8 Mar, 2011) means 1 Feb, 2011 + 1 month + 1 day, that represents 2 Feb, 2011 as well

以下は日付ストリングを作成する別の方法です:

Code Block
date(day: dd, month: MM, year: YYYY)
date(d: dd, m: MM, y: YYYY)
date(week: w, year: YYYY)
date(quarter: q, year: YYYY)

日付時刻内容の変更

日付時刻と何か、以下の例を参照して下さい。日時コンテキストとは何か? 以下の例を参照して下さい。

 

01/2011

02/2011

03/2011

フォーミュラインディケーター数式インジケータ

1000

1200

1300

フォーミュラはそれぞれの列で評価されます数式はそれぞれの列で評価されますこの例では列に特定の月の評価値があります。値1000の評価中、日付時刻内容は01/2011でしたが、値1200の処理中は02/2011でした。

機能

説明

Object dateAt(String dateString, { expression })

評価表現の内容をdateString日付に変えます。例:

Code Block
dateAt('2011-01-01', {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Object dateInterval(String from, String to, { expression })

表現の日付内容を変更し特定のインターバルfrom - toに集合体として評価します。例:

Code Block
dateInterval('2011-01-01', '2011-12-31' {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

インディケーターの値インジケータの値M_NAME_1M_NAME_2は全期間で集合体となります。

Object timeAt(String timeString, { expression })

評価表現の内容をtimeString日付に変更します。例:

Code Block
timeAt('13:33:23', {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

Object timeInterval(String from, String to, { expression })

表現の時刻内容を変更し特定のインターバルfrom - toに集合して評価します。例:

Code Block
timeInterval('00:00:01', '23:59:59' {
i1 = M_NAME_1
i2 = M_NAME_2
if (i1 > i2) {
  return i1;
}
return i2;
});

インディケーターインジケータM_NAME_1M_NAME_2の値は全期間で集合されています。

Object dateAt (String date, String period) { expression })

評価表現の内容をdateString日付に変えます- {DAY, D, WEEK, W, MONTH, M, YEAR, Y}の定義期間によって集合されます。

Object dateInterval (String from, String to, String period ) { expression })

表現の日付内容を変え、特定のインターバルfrom - toに集合されて評価します。定義期間{DAY, D, WEEK, W, MONTH, M, YEAR, Y}による集合も実行されます。

Object minus(String date, period, int)

特定の期間(年、月、週、日)の数を定義された日付値に引きます。

Code Block
minus(date(firstValue('L_DATE')), 'days', 20) //subtracts 20 days from the date value
Object minus(String time, period, int)

特定の期間(年、月、週、日)の数を定義された日付値に追加します。

Code Block
minus(time(firstValue('L_TIME')), 'minutes', 30) //subtracts 30 minutes from the time value
Object plus(String date, period, int)

特定の期間(年、月、週、日)の数を定義された日付値に追加します。

Code Block
plus(date(firstValue('L_DATE')), 'days', 20) //adds 20 days to the date value
Object plus(String time, period, int)

特定の期間(時間、分、秒)の数を定義された日付値に追加します。

Code Block
plus(time(firstValue('L_TIME')), 'seconds', 50) //adds 50 seconds to the time value

Object timeAt (String time, String period) { expression })

評価表現のコンテクストをtimeString時刻に変更します- 定義期間{HOUR, H, MINUTE, SECOND}によって集合されます。

Object timeInterval (String from, String to, period) { expression })

表現の時刻コンテクストを変更し、特定のインターバルfrom - toに集合されて評価します。定義された期間{HOUR, H, MINUTE, SECOND}による集合も実行されます。

Object withoutDateTime() { expression })

日付時刻インターバルなしで表現を評価します。

廃止した機能

Warning

これらの機能は以降のリリースで取り除かれる可能性があります。

機能

説明

Object value(String dateString, String indicator)

特定の日付でインディケーター値をロードします。特定の日付でインジケータ値をロードします。

Object value(String dateString, int drill_down_level)

Nの以前レベルに集合された特定の日付でインディケーター値をロードします。の以前レベルに集合された特定の日付でインジケータ値をロードします。

Object value(String dateFrom, String dateTo, String indicator)

特定の日付インターバルの累積インディケーター値をロードします。特定の日付インターバルの累積インジケータ値をロードします。

Object value(String dateFrom, String dateTo, String indicator, int dril_down_level)

Nの以前レベルに集合された特定の日付インターバルの累積インディケーター値をロードします。の以前レベルに集合された特定の日付インターバルの累積インジケータ値をロードします。

より先進的な機能

 

機能

説明

Number cumulateFromDate(String startDate, String indicator)

この機能は現在の値を徐々に累積値に追加します。例:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

cumulateFromDate('2011-01-01', 'M_NAME_1')

1000

2200

3500

Number cumulateFromTime(String startTime, String indicator)

この機能は現在の値を徐々に累積値に追加します。例:

Section
Column

 

00:01

00:02

00:03

M_NAME_1

1000

1200

1300

cumulateFromTime('00:01', 'M_NAME_1')

1000

2200

3500

prev(String indicatorCode)

以前の日付や時刻値に計算されたパスされたインディケーター値以前の日付や時刻値に計算されたパスされたインジケータ値(.以前の月、日、時間)。例:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

prev('M_NAME_1')

 

1000

1200

Number prev(String indicatorCode, int prevLevelAgg)

以前の日付や時刻値に計算されたパスされたインディケーター値以前の日付や時刻値に計算されたパスされたインジケータ値(.以前の月、日、時間)。パラメーターprevLevelAggは集合が必要な以前レベルの数を表しています。

Number next(String indicatorCode)

次の日付や時刻値に計算されたパスされたインディケーター値次の日付や時刻値に計算されたパスされたインジケータ値(.以前の月、日、時間)。例:

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

next('M_NAME_1')

1200

1300

 

Number next(String indicatorCode, int prevLevelAgg)

次の日付や時刻値に計算されたパスされたインディケーター値次の日付や時刻値に計算されたパスされたインジケータ値(.以前の月、日、時間)。パラメーターprevLevelAggは集合が必要な以前レベルの数を表しています。

int daysBetween(DateTime dateFrom, DateTime dateTo)

この機能は提供日の間の日数を計算します。

int daysBetween(DateTime dateFrom, DateTime dateTo, int[])

この機能は提供日の間の日数を計算し、週の選択した日を除外します。曜日は数字で表されます:1は月曜日、7は日曜日です。

以下の例は、計算から土曜と日曜を取り除く方法を示しています。

Code Block
daysBetween(date(firstValue('L_DATE_FROM'),date(firstValue('L_DATE_TO'), 6,7)

int daysBetween(LocalDate dateFrom, LocalDate dateTo)

この機能は提供日の間の日数を計算します。

int monthsBetween(DateTime dateFrom, DateTime dateTo)

この機能は提供日の間の月数を計算します。

int monthsBetween(LocalDate dateFrom, LocalDate dateTo)

この機能は提供日の間の月数を計算します。

int yearsBetween(DateTime dateFrom, DateTime dateTo)

この機能は提供日の間の年数を計算します。

int yearsBetween(LocalDate dateFrom, LocalDate dateTo)

この機能は提供日の間の年数を計算します。

評価表現の全コンテクストの変更には、以下の機能を使うことができます:

Number prev(String period, { expression })

表現のコンテクストを希望の以前の日付期間に変更します。period パラメーターの値は以下の1つです: DAY, WEEK, MONTH, QUARTER, YEAR. :

Section
Column

 

01/2011

02/2011

03/2011

M_NAME_1

1000

1200

1300

prev(MONTH) { M_NAME_1 } 

 

1000

1200

Number next(String period, { expression })

表現のコンテクストを希望の次の日付期間に変更します。period パラメーターの値は以下の1つです: DAY, WEEK, MONTH, QUARTER, YEAR. :

次の例は、表/チャートの日付時刻入力の1年前にロードされた値の処理です。

Code Block
return prev(YEAR) {
  M_NAME_1 / M_NAME_2 * 100
}
Info

フルネーム(Y,Q,M,W,D)の代わりに、時間単位の最初の文字のみ(フォーミュラを変える時間コンテクストの場合数式を変える時間コンテクストの場合)を入力することもできます。例えばprev(Y){}

入れ子表現

日付時刻機能は組み合わせられます(対応できる場合)、例: 128 2010, 9:04:02AMM_INDICATOR :

Code Block
dateAt ('2010-12-08') { timeAt('09:04:02') { M_INDICATOR } }

Next Steps

...