この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

substr()

指定された位置で始まるサブ文字列を返します。返されるサブ文字列の長さを指定することもできます。

構文

substr(string,position[, length])

使用方法

substr は、string 内の位置 position から始まる文字を返します。length を指定すると、この関数は length 個の文字を返します。いずれかのパラメーターが null の場合、関数は null を返します。length は省略可能です。

string の最初の文字の位置は 1 です。position が負の場合、位置は文字列の末尾に対する相対位置になります。したがって、-1 の position は最後の文字を示します。

length が負の場合、関数は null を返します。position > len (string)、position < -len(string)、または position = 0 の場合、空の文字列が返されます。

1-- we want a substring that is one character long, starting at position 1. 
2-- The character "C" is returned.
3substr("CRM", 1, 1)
4
5-- we want a substring that is 2 characters long, starting at position 1
6-- The string "CR" is returned
7substr("CRM", 1, 2) == "CR"
8
9-- we want a substring that is two characters long, starting from the *end* of the string
10-- The string "RM" is returned
11substr("CRM", -2, 2) == "RM"
12
13-- we want to get the first 10 characters from this string
14-- the string "2018-03-16" is returned
15substr("2018-03-16T00:00:03.000Z",10)

現在の日付ではなく、現在の時刻を表示するとします。substr() を使用して、date_to_string() から最後の 11 文字が返されるようにします。
1q = foreach q generate substr(date_to_string(now(), "yyyy-MM-dd HH:mm:ss"), -11) as 'Time Now';