为什么DB2 CHAR()函数返回'24:00:00'表示00:00:00的时间字段?

时间:2022-06-01 21:20:22

I'm querying DB2 on i (AS/400). A plain SELECT statement on a column with datatype of TIME returns 00:00:00, but when I use the CHAR() function it returns '24:00:00'.

我在i上查询DB2(AS / 400)。数据类型为TIME的列上的普通SELECT语句返回00:00:00,但是当我使用CHAR()函数时,它返回'24:00:00'。

I understand that 24:00:00 is a valid time, but why would CHAR() return 24 when the native TIME returs 00?

我知道24:00:00是一个有效的时间,但是为什么当本地TIME回归00时CHAR()会返回24?

1 个解决方案

#1


On V5R4:

CREATE TABLE TEST (FIELD1 TIME NOT NULL WITH DEFAULT)

INSERT INTO TEST VALUES('00:00:00')

SELECT FIELD1, CHAR(FIELD1) FROM TEST

Shows:

FIELD1    CHAR ( FIELD1 ) 
00:00:00     00:00:00     

Not sure why you are getting 24:00:00.

不知道你为什么要24:00来。

I also tried:

我也尝试过:

INSERT INTO TEST VALUES('24:00:00')

thinking maybe a 24:00:00 value was displaying as '00:00:00' but this shows:

想也许24:00:00的值显示为'00:00:00',但这显示:

FIELD1    CHAR ( FIELD1 ) 
00:00:00     00:00:00     
24:00:00     24:00:00    

for pretty much all Time formats (*HMS, ISO).

适用于所有时间格式(* HMS,ISO)。

#1


On V5R4:

CREATE TABLE TEST (FIELD1 TIME NOT NULL WITH DEFAULT)

INSERT INTO TEST VALUES('00:00:00')

SELECT FIELD1, CHAR(FIELD1) FROM TEST

Shows:

FIELD1    CHAR ( FIELD1 ) 
00:00:00     00:00:00     

Not sure why you are getting 24:00:00.

不知道你为什么要24:00来。

I also tried:

我也尝试过:

INSERT INTO TEST VALUES('24:00:00')

thinking maybe a 24:00:00 value was displaying as '00:00:00' but this shows:

想也许24:00:00的值显示为'00:00:00',但这显示:

FIELD1    CHAR ( FIELD1 ) 
00:00:00     00:00:00     
24:00:00     24:00:00    

for pretty much all Time formats (*HMS, ISO).

适用于所有时间格式(* HMS,ISO)。