23 Replies Latest reply on Sep 23, 2010 3:47 AM by Adam Cameron.

    Passing Dates to a cfc

    Daniel Pride Level 1

      I am trying to pass a date to a  cfc and get a numeric response

      I test the service in Flashbuilder and it works fine when I type in a value of 09/20/2010

      It returns the numeric sum as expected....

       

      If I change the cfc to a string and refresh the service this also works (2010/09/20)

       

      But when I try to call it nothing and I mean nothing works.

      Not this....

                         var theDate:Date = new Date();

                         sumDateLineItemsResult.token = lineItemsService.sumDateLineItems(theDate);

                           lineItemsService.commit();

      nor this....
                      sumDateLineItemsResult.token = lineItemsService.sumDateLineItems(new Date(2010,09,20));
                      lineItemsService.commit();

       

      nor a call with a string variable after the cfc has been modified to accept strings....

       

      The cfc...

       

          <cffunction name="sumDateLineItems" output="false" access="remote" returntype="numeric" >
              <cfargument name="theDate" type="date" required="true" />
              <cfset var qSum="">
              <cfquery name="qsum" datasource="BlueRose">
                   SELECT SUM(Price) AS daysTotal FROM LineItems WHERE AptDate =  <CFQUERYPARAM CFSQLTYPE="CF_SQL_DATE"                 VALUE="#ARGUMENTS.theDate#">
              </cfquery>
              <cfif len(qsum.daysTotal) EQ 0>
                  <cfset qsum.daysTotal="0">
              </cfif>
              <cfreturn qsum.daysTotal>   
          </cffunction>

       

      It seems to simple and obvious but I am stumped ! Any help from a coldfusion maven would be greatly appreciated.

      Thanks

      Dan Pride