|
发表于 2013-12-8 15:47:28
|
显示全部楼层
Format of the Data Type DATE_AND_TIME
When you enter date and time using the DATE_AND_TIME data type (DT), your entries are stored in binary coded decimal format in 8 bytes. The DATE_AND_TIME data type has the following range:
DT#1990-1-1-0:0:0.0 to DT#2089-12-31-23:59:59.999
The following examples show the syntax for the date and time for Thursday, December 25, 1993, at 8:12 and 34,567 seconds in the morning. The following two formats are possible:
DATE_AND_TIME#1993-12-25-8:12:34.567
DT#1993-12-25-8:12:34.567
The following special IEC (International Electrotechnical Commission) standard functions are available for working with the DATE_AND_TIME data type:
Convert date and time of day to the DATE_AND_TIME format
FC3: D_TOD_DT
Extract the date from the DATE_AND_TIME format
FC6: DT_DATE
Extract the day of the week from the DATE_AND_TIME format
FC7: DT_DAY
Extract the time of day from the DATE_AND_TIME format
FC8: DT_TOD
The following table shows the contents of the bytes that contain the date and time information for the example Thursday, December 25, 1993, at 8:12 and 34,567 seconds in the morning.
Byte
Contents
Example
0
Year
B#16#93
1
Month
B#16#12
2
Day
B#16#25
3
Hour
B#16#08
4
Minute
B#16#12
5
Second
B#16#34
6
Two most significant digits of MSEC
B#16#56
7
(4MSB)
Two least significant digits of MSEC
B#16#7
7
(4LSB)
Day of week
1 = Sunday
2 = Monday
...
7 = Saturday
B#16#_5
The permitted range for the data type DATE_AND_TIME is:
min.: DT#1990-1-1-0:0:0.0
max.: DT#2089-12-31-23:59:59.999
Possible Value Range
BCD Code
Year
1990 - 1999
2000 - 2089
90 - 99
00 - 89
Month
1 - 12
01 - 12
Day
1 - 31
01 - 31
Hour
00 - 23
00 - 23
Minute
00 - 59
00 - 59
Second
00 - 59
00 - 59
Millisecond
0 - 999
000 - 999
Day of week
Sunday - Saturday
1 - 7
这是step7在线帮助中的内容,你直接要定义date and time类型的变量然后直接取其中的字节就可以了。 |
|