将oracle sql时间戳转换为char coldfusion

时间:2014-07-30 08:42:29

标签: sql oracle coldfusion timestamp to-char

我想要做的是将oracle时间戳转换为to_char,以便人眼可以读取它。

以下是我的SQL代码:

<cfquery datasource="#application.dsn#" name="hdlbillDetails">
    SELECT BILLID, FIRSTNAME, 
           LASTNAME, RESIDENCE, 
           STREET, TOWN, 
           COUNTRY, AMMOUNTDUE, 
           to_char(DATEDUE,'YYYY-MM-DD HH24:MI:SS'), 
           to_char(DATEISSUES,'YYYY-MM-DD HH24:MI:SS')
    FROM Details
    WHERE BillID = #billId#
</cfquery>

显示的错误如下:

Caused by: coldfusion.runtime.UndefinedElementException: 
Element DATEDUE is undefined in HDLBILLDETAIL

2 个答案:

答案 0 :(得分:8)

未经测试,但试试这个。在计算中可能只需要别名:

<cfquery datasource="#application.dsn#" name="hdlbillDetails">
    SELECT BILLID, FIRSTNAME, 
           LASTNAME, RESIDENCE, 
           STREET, TOWN, 
           COUNTRY, AMMOUNTDUE, 
           to_char(DATEDUE,'YYYY-MM-DD HH24:MI:SS') as DATEDUE, 
           to_char(DATEISSUES,'YYYY-MM-DD HH24:MI:SS') as DATEISSUES
    FROM Details
    WHERE BillID = #billId#
</cfquery>

答案 1 :(得分:2)

尝试使用别名,例如

<cfquery datasource="#application.dsn#" name="hdlbillDetails">
    SELECT d.BILLID, d.FIRSTNAME, 
           d.LASTNAME, d.RESIDENCE, 
           d.STREET, d.TOWN, 
           d.COUNTRY, d.AMMOUNTDUE, 
           to_char(d.DATEDUE,'YYYY-MM-DD HH24:MI:SS') as DATEDUE, 
           to_char(d.DATEISSUES,'YYYY-MM-DD HH24:MI:SS') as DATEISSUES
    FROM Details d
    WHERE d.BillID = #billId#
</cfquery>