ColdFusion & MySql 日期格式

ColdFusion & MySql Date Formats

我正在使用表单将日期添加到我的 MySQL 数据库中。该列的数据类型为 datetime,列名称为 _date

要输出我的数据,我使用以下代码:

<cfoutput>
    <cfquery name="vehiclelogDate" datasource="#datasource#">
        select ID, '_date'
        from   vehicle_log
        where  vehicle_id = <cfqueryparam value="#url.id#">
        order by _date ASC
    </cfquery>

    <cfset fist_year = DATEPART("yyyy",'#vehiclelogDate._date#')>

    #first_year#
</cfoutput>

当我这样做时,我收到错误:值 _date 无法转换为日期。

我最近从 Access 测试数据库转换为 MYSQL,现在出现了这个错误。

有人可以帮忙吗?

这个:

select ID, '_date'

它不返回 ID_date 列,而是返回 ID 列和 string _date .

你想要这样的东西:

select ID, _date