An
item of type TIMESTAMP is a series of one to twenty single-byte numeric digits
that reflect a specific moment. The meaning of each digit is determined by
the mask that you specify when declaring the item.
The following characters
are available, in order, when you specify the mask:
- yyyy
- Four digits that represent the year. The range is 0000 to 9999.
- MM
- Two digits that represent the month. The range is 01 to 12.
- dd
- Two digits that represent the day. The range is 01 to 31.
- HH
- Two digits that represent the hour. The range is 00 to 23.
- mm
- Two digits that represent the minute. The range is 00 to 59.
- ss
- Two digits that represent the second. The range is 00 to 59.
- f
- Zero to six digits that each represent a fraction of seconds; the first
represents tenths, the second represents hundreds, and so on.
The default mask is yyyyMMddHHmmss.
When
you interact with DB2
® (directly or by way of JDBC) , you must specify every component from year
(
yyyy) through seconds (
ss). In other contexts, the following
is true:
The internal hexadecimal representation of an example value is
as follows if the default mask (
yyyyMMddHHmmss) is in effect and if
the item is on a host environment which
uses EBCDIC:
// 8:05:10 o'clock on 12 January 2005
F2 F0 F0 F5 F0 F1 F1 F2 F0 F8 F0 F5 F1 F0
The internal hexadecimal representation of an example value
is as follows if the default mask (yyyyMMddHHmmss) is in effect and
if the item is on a workstation environment like Windows® 2000, which uses ASCII:
// 8:05:10 o'clock on 12 January 2005
32 30 30 35 30 31 31 32 30 38 30 35 31 30
An item of type TIMESTAMP can be compared with (or assigned
to or from) an item of type TIMESTAMP or an item of type DATE, TIME, NUM,
or CHAR. However, an error occurs at development time if you assign a value
that is not valid. An example is as follows:
// NOT valid because February 30 is not a valid date
myTS timestamp("yyyymmdd");
myTS = "20050230";
If characters at the beginning of
a full mask are missing (for example, if the mask is "dd"), EGL assumes that
the higher-level characters ("yyyyMM", in this case) represent the current
moment, in accordance with the machine clock. The following statements cause
a runtime error in February:
// NOT valid because February 30 is not a date
myTS timestamp("dd");
myTS = "30";
Finally, an item of type TIMESTAMP can receive
data from or provide data to a relational database.