Skip to main content
Participating Frequently
May 22, 2008
Question

Code Help

  • May 22, 2008
  • 1 reply
  • 324 views
Using mysql 5x with lastest coldfusion...any help or ideas is appreciated...I think I've just looked at it too long.

Here's what I got:

<cfsilent><cfsetting enablecfoutputonly="yes">
<!--- The Calendar Parameters start --->
<cfparam name="url.m" default="#datepart("m", now())#">
<cfparam name="url.y" default="#datepart("yyyy", now())#">
<cfset dateob=CreateDate(URL.y,URL.m,1)>
<cfset ly = #url.y#>
<cfset ny = #url.y#>
<cfset daybuilder = arraynew(1)>
<cfloop index="c" from="1" to="#DaysInMonth(DateOb)#">
<cfset daybuilder[#c#]="no">
</cfloop>
<cfquery name="load_calendar" datasource="#request.dsn#">
SELECT blog_date,(day(blog_date)) AS getthisday
FROM blog_posts
WHERE (blog_date >= #CreateDate(Year(DateOb),Month(DateOb),1)#) and (blog_date <= #CreateDate(Year(DateOb),Month(DateOb),DaysInMonth(DateOb))#)
</cfquery>
<cfoutput query="load_calendar" group="blog_date">
<cfset daybuilder[#getthisday#]="yes">
</cfoutput>
<cfsetting enablecfoutputonly="no">
</cfsilent>

Here's my error:

SELECT blog_date,(day(blog_date)) AS getthisday
14 : FROM blog_posts
15 : WHERE (blog_date >= #CreateDate(Year(DateOb),Month(DateOb),1)#) and (blog_date <= #CreateDate(Year(DateOb),Month(DateOb),DaysInMonth(DateOb))#)
16 : </cfquery>
17 : <cfoutput query="load_calendar" group="blog_date">


--------------------------------------------------------------------------------

SQLSTATE 42000
SQL SELECT blog_date,(day(blog_date)) AS getthisday FROM blog_posts WHERE (blog_date >= {ts '2008-05-01 00:00:00'}) and (blog_date <= {ts '2008-05-31 00:00:00'})
VENDORERRORCODE 1064


    This topic has been closed for replies.

    1 reply

    Inspiring
    May 22, 2008
    Your query has more brackets in it than I would use but that shouldn't matter. In any event, it looks ok. To troubleshoot, take the day function out of the select clause and run it again. Maybe that will help narrow it down.
    Inspiring
    May 22, 2008
    Try using cfqueryparam so that your database understands that you are passing date parameters.
    Also verify that "(day(blog_date)) AS getthisday" is valid syntax for MySQL.

    cfqueryparam: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_18.html#1102474

    See attached sample.

    Edit: corrected pound signs in sample.
    Inspiring
    May 22, 2008
    See corrected sample.