ColdFusion CreateDate问题 [英] Coldfusion CreateDate Issue

查看:164
本文介绍了ColdFusion CreateDate问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CreateDate()函数中遇到一些麻烦,它只是错误,我不知道为什么!

I'm having some trouble with the CreateDate() function, it's just erroring and I have no idea why!

我运行此查询以获取新闻报道中的所有日期,以便每月创建一个新闻存档。

I am running this query to get all of the dates from news stories so that I can create a news archive monthly.

<cfquery name="selectNews" datasource="#Request.dsn#">
    SELECT Month(NewsDate) AS theCount
    FROM news
    GROUP BY Month(NewsDate)
</cfquery>

然后当我输出它,我试图以以下格式输出

Then when I output it, I'm trying to output it in the following format


      2012年8月
    • 2012年9月


    • Aug 2012
    • Sept 2012
    • Oct 2012

    所以我使用下面的代码尝试输出这个列表

    So I'm using the following code to try to output this list

    <ul>
    <cfloop query="selectNews">
        <cfoutput>
        <cfset theDay = DateFormat(Now(), 'dd')>
            <cfset theMon = theCount>
            <cfset theYear = DateFormat(Now(), 'yyyy')>
            <li>#CreateDate(theYear, theMon, theDay)#</li>
        </cfoutput>
    </cfloop>
    </ul>
    

    它适用于第一个项目,将输出 2012年8月,然后会报错

    It works fine for the first item, it will output Aug 2012, however it will then error, saying this

    Error Occurred While Processing Request
    MONTH
    

    对我来说,至少是没用的!

    Which to me, at least, is useless!

    推荐答案

    这是我是一个白痴。我使用 DateFormat(Now(),'dd'),这是一个巨大的愚蠢的错误,看到9月只有30天。它运行 CreateDate(2012,09,31),这显然不会工作!

    This was me being an idiot. I was using DateFormat(Now(), 'dd'), which is a huge stupid mistake, seeing as there is only 30 days in September. It was running CreateDate(2012, 09, 31), which obviously won't work!

    这篇关于ColdFusion CreateDate问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆