标签:
1 TO_CHAR(FIRDATE - (TO_DATE(TO_CHAR(FIRDATE ,‘YYYY/MM/DD‘) || ‘07:30:00‘,‘YYYY/MM/DDHH24:MI:SS‘) - TRUNC(SYSDATE)),‘MM/DD ‘) 2 || (CASE WHEN TO_NUMBER(TO_CHAR(FIRDATE - 0.5 / 24,‘HH24‘)) >=7 3 AND TO_NUMBER(TO_CHAR(FIRDATE - 0.5 / 24,‘HH24‘)) <19 THEN ‘D‘ ELSE ‘N‘ END) INPUTDATE 4 5 FROM (SELECT A.UPN UPN, 6 C.DESCRIPTION DESCRIPTION, 7 MIN(CASE WHEN A.STAGE=‘IJ‘ THEN A.FIRSTTESTDATE END) FIRDATE 8 FROM ALLIE_USNYRDATA A,SFCUSN B,ERPITEMMASTER C 9 WHERE A.USN=B.USN 10 AND B.UPN=C.CPN 11 GROUP BY ......
注意TO_DATE,TO_CHAR 之间的转换。
存在FIRDATE - 0.5 / 24运算,故为date型。小的查询里面FIRDATE为date型。TO_date()—>TO_CHAR()—>TO_NUMBER().
后面连接为char型。故FIRDATE再转为CHAR型。
例如:
SELECT to_date(‘2010-08-19 18:05:09‘,‘yyyy-mm-dd‘) FROM dual
这样的格式是不允许的,经过修改为:
SELECT to_date(‘2010-08-19‘,‘yyyy-mm-dd‘) FROM dual;
PLSQL语句执行正确,而VB执行错误。ORA-01830 date format picture ends before converting entire input string
标签:
原文地址:http://www.cnblogs.com/xxh-2014/p/4286223.html