替换concat sql的时间格式

时间:2013-03-05 22:40:11

标签: sql peoplesoft

现在我有两个字段:

MEETING_TIME_START  |    MEETING_TIME_END
--------------------+--------------------
 9:30:00.000000AM   |   10:50:00.000000AM
11:00:00.000000AM   |   12:20:00.000000PM
11:00:00.000000AM   |   12:20:00.000000PM
10:00:00.000000AM   |   10:50:00.000000AM

我有一个标准来创建一个新字段并重新格式化时间:

(SUBSTR((D.MEETING_TIME_START),1,5)%concat '- ' %concat SUBSTR((D.MEETING_TIME_END),1,5))

结果如下:

NEW FIELD
------------
09.30- 10.50
11.00- 12.20
11.00- 12.20
10.00- 10.50

如何调整标准以创建此格式:

PREFERRED OUTPUT
----------------
0930-1050
1100-1220
1100-1220
1000-1050

2 个答案:

答案 0 :(得分:0)

你能试试吗?

(SUBSTR((D.MEETING_TIME_START),1,2) || SUBSTR((D.MEETING_TIME_START),4,2) || '-' || SUBSTR((D.MEETING_TIME_END),1,2) || SUBSTR((D.MEETING_TIME_START),4,2))

答案 1 :(得分:0)

如果是MySQL,我会试试这个:

CONCAT(SUBSTR(D.MEETING_TIME_START,1,2),SUBSTR(D.MEETING_TIME_START,4,2),'-',SUBSTR(D.MEETING_TIME_END,1,2), SUBSTR(D.MEETING_TIME_END,4,2))