d は、日付を表す文字列式です。指定されていない場合、DAYS は DATETIME() で返された値を使用します。d の値は計算型としなければなりませんが、文字型にできるようにもする必要があります。そうでない場合、DAYS 関数は d を文字に変換します。
p は、サポートされている日付/時刻パターンです。指定されていない場合、DAYS は値 YYYYMMDDHHMISS9999 を使用します。d の値と同様に、p は計算型としなければなりませんが、文字型にできるようにもする必要があります。そうでない場合、DAYS 関数は p を文字に変換します。
w は、2 桁の年の形式に使用する世紀ウィンドウの整数の式の値です。
この例では、DAYS 関数を使用して、リリアン暦の開始日から指定した日付までの日数を返します。
dt: proc options(main);
dcl wkdays (7) char (6) var static init ('Sun', 'Mon', 'Tue', 'Weds', 'Thurs', 'Fri', 'Sat');
dcl (string, pattern) char (80) var ;
dcl str char (80) var;
dcl f float bin (52);
dcl d fixed bin (31);
d = 0;
string = '14.02.2014';
pattern = 'DD.MM.YYYY';
put skip;
d= days(string, pattern, 0);
put skip list ('On Feb 14, 2014, ' || trim(d) || ' days elapsed since the start of the Lilian calendar.');
put skip;
put skip list ('Feb 14, 2014 was on a ' || wkdays(weekday(d)));
put skip;
f= secs(string, pattern, 0);
put skip list ('On Feb 14, 2014, ' || trim(f) || ' seconds elapsed since the start of the Lilian calendar.');
put skip;
put skip list ('Converting the number of days elapsed back to the original pattern: ');
str = daystodate(d, pattern);
put skip list (str);
put skip;
put skip list ('Converting the number of seconds elapsed back to the original pattern: ');
str = secstodate(f, pattern);
put skip list (str);
put skip;
put skip list ("Converting the original date/time stamp to 'YYYYMMDD' : ");
str = repattern((str), 'YYYYMMDD', pattern, 1976);
put skip list (str);
end;
上記のコード サンプルの出力は次のようになります。
On Feb 14, 2014, 157543 days elapsed since the start of the Lilian calendar.
Feb 14, 2014 was on a Fri
On Feb 14, 2014, 1.361171520000000E+010 seconds elapsed since the start of the Lilian calendar.
Converting the number of days elapsed back to the original pattern:
14.02.2014
Converting the number of seconds elapsed back to the original pattern:
14.02.2014
Converting the original date/time stamp to 'YYYYMMDD' :
20140214
説明
DAYS 組み込み関数は、日付/時刻パターン文字列に対応する日数、または現在の日付に対応する日数を返します。
リリアン形式およびサポートされている日付/時刻パターンの詳細については、ヘルプ トピックの「日付/時刻組み込み関数」を参照してください。