时间戳问题

TimeStamp issue

我在使用这段代码时遇到了问题:

DECLARE FormattedTimeStamp TIMESTAMP;
DECLARE pattern CHARACTER 'yyyy-mm-ddTHH:mm:ss';
SET FormattedTimeStamp = CAST(EnvRef.ConsumerTrxnsInq.paymentList[i].TransactionDate as DATE FORMAT 'yyyy-MM-dd');
SET OutputRoot.XMLNSC.ns:ConsumerTrxnsInqRs.Body.ConsumerTransaction[i].Timestamp = CAST(REPLACE(SUBSTRING(CAST(FormattedTimeStamp AS CHAR) before '.'),' ','T') AS TIMESTAMP FORMAT pattern);

当我运行它时,它产生这个错误:

Error while casting. subParse failed. TIMESTAMPT'2014-12-02T15:39:21. yyyy-mm-ddTHH:mm:ss. TIMESTAMPT'2014-12-02T15:39:21. yyyy.

有什么帮助吗?

如果你使用 T-SQL,那么 首先替换

DECLARE FormattedTimeStamp TIMESTAMP

DECLARE @FormattedTimeStamp TIMESTAMP

您定义的模式有问题。请更正如下.. 它应该工作..

  DECLARE pattern CHARACTER 'yyyy-MM-dd''T''HH:mm:ss';