Current timestamp—%CURTMSTP
Use this function when you want CDC Replication to track the date and time when it inserts or updates a row in source and target columns.
Syntax
%CURTMSTP(timezone
)Parameters
- timezone
- Specifies the time zone of the result. You must enclose values
of this parameter in double or single quotation marks.
- *LOC
- Returns the time local to the source or target.
- *UTC
- Returns the time in Coordinated Universal Time (UTC).
- *GMT
- Returns the time in Greenwich Mean Time (GMT). This is the same as *UTC.
Result data type
Character string, in the format CCYY-MM-DD-HH.MM.SS.UUUUUU, where UUUUUU represents the number of microseconds. For example, 2008-12-09-03.11.34.849217. For environments that do not support microsecond precision, zeroes will be used to right-pad the result to a six-digit length. In the examples for this function, the results do not show microseconds.If you want you want to convert the character string to a timestamp format, see the sample provided in the Examples section.
Examples
%CURTMSTP(*LOC
)If the local time is 2:05:54 AM on June 18, 2005, this function returns 2005-06-18-02.05.54.
%CURTMSTP(*UTC
) For a server located in the Japan Standard Time (JST) zone, at 4:31:01 AM on September 22, 2011, this function returns 2011-09-21-19.31.01. JST is 9 hours ahead of UTC (UTC+9).
%CURTMSTP(*GMT
)For
a server located in the Japan Standard Time (JST) zone, at 4:31:01
AM on September 22, 2011, this function returns 2011-09-21-19.31.01.
JST is 9 hours ahead of UTC (UTC+9). This example is equivalent to
%CURTMSTP(*UTC
).
%SUBSTRING(%CURTMSTP("*UTC"),
1, 16) Returns the date and time (hours and minutes only) of the %CURTMSTP function invocation in UTC. You can use this example if you do not require the number of seconds and microseconds.
For
example, if the %CURTMSTP function is invoked on a server located
in the Western Standard Time (WST) zone on April 24, 2014 at 4:05:22
AM, the expression returns 2014-04-23-20.05
. WST is 8 hours
ahead of UTC (UTC+8). The %SUBSTRING function converts the date to
a character string and returns the first 16 characters of the timestamp
returned by the %CURTMSTP function.
%TODATETIME(%SUBSTRING(%CURTMSTP(*LOC
),
1, 10), *YYMD
, %SUBSTRING(%CURTMSTP(*LOC
), 12, 8))Returns the date and time (hours, minutes and seconds only; microsecond precision will not be preserved) of the %CURTMSTP function invocation in the timestamp format.