Skip to main content
Inspiring
April 23, 2008
Question

CFC return type question

  • April 23, 2008
  • 14 replies
  • 771 views
Does the return type date only handle the 'date' and not the date & time????

Because it doesn't appear to be returning the time portion to be input into
our database.....

<cffunction name="calcDate" access="public" returntype="date"
> hint="Returns 1st Saturday of Month">
> <cfargument name="id" type="numeric" required="yes">
> <cfset var GetTournDate = "">
> <cfset var tourndate = "">
> <cfset var FirstOfMonth2MonthsAhead = "">
> <cfset NewTournDate = "">
> <cfquery name="GetTournDate" datasource="SalleBoise">
> select TournDateTime
> from clubtournaments
> where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
> value="#arguments.id#">
> </cfquery>
> <cfset tourndate = GetTournDate.TournDateTime>
> <cfset FirstOfMonth2MonthsAhead = createdatetime(year(dateadd('m', 2,
> tourndate)), month(dateadd('m', 2, tourndate)), 01, hour(tourndate),
> minute(tourndate), second(tourndate))>
> <cfset NewTournDate = dateadd('d',
> 7-dayofweek(FirstOfMonth2MonthsAhead), FirstOfMonth2MonthsAhead)>
> <cfreturn NewTournDate />
> </cffunction>


    This topic has been closed for replies.

    14 replies

    Inspiring
    April 25, 2008
    Ok, here are the results:

    Ok, got it to work, and the info that it shows me is:

    {ts '2008-07-05 15:00:00'}


    "Steve Grosz" <boise_bound@hotmail.com> wrote in message
    news:fum7tl$1an$1@forums.macromedia.com...
    > Does the return type date only handle the 'date' and not the date &
    > time????
    >
    > Because it doesn't appear to be returning the time portion to be input
    > into our database.....
    >
    > <cffunction name="calcDate" access="public" returntype="date"
    >> hint="Returns 1st Saturday of Month">
    >> <cfargument name="id" type="numeric" required="yes">
    >> <cfset var GetTournDate = "">
    >> <cfset var tourndate = "">
    >> <cfset var FirstOfMonth2MonthsAhead = "">
    >> <cfset NewTournDate = "">
    >> <cfquery name="GetTournDate" datasource="SalleBoise">
    >> select TournDateTime
    >> from clubtournaments
    >> where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
    >> value="#arguments.id#">
    >> </cfquery>
    >> <cfset tourndate = GetTournDate.TournDateTime>
    >> <cfset FirstOfMonth2MonthsAhead = createdatetime(year(dateadd('m', 2,
    >> tourndate)), month(dateadd('m', 2, tourndate)), 01, hour(tourndate),
    >> minute(tourndate), second(tourndate))>
    >> <cfset NewTournDate = dateadd('d',
    >> 7-dayofweek(FirstOfMonth2MonthsAhead), FirstOfMonth2MonthsAhead)>
    >> <cfreturn NewTournDate />
    >> </cffunction>
    >
    >


    Inspiring
    April 24, 2008
    Ok, got it to work, and the info that it shows me is:

    {ts '2008-07-05 15:00:00'}

    "Azadi" <azadi@sabai-dee.com> wrote in message
    news:fuq541$agq$1@forums.macromedia.com...
    > <cfinvoke component="..." method="..." RETURNVARIABLE="somenamehere">
    > <cfoutput>#somenamehere#</cfoutput>
    >
    > Azadi Saryev
    > Sabai-dee.com
    > http://www.sabai-dee.com/


    Inspiring
    April 24, 2008
    > Does the return type date only handle the 'date' and not the date & time????

    It handles date objects, which contain and date and a time portion.


    > Because it doesn't appear to be returning the time portion to be input into
    > our database.....

    That would probably be because the time information is absent from the
    underlying data.

    At the end of your method code, just before the return statement, dump the
    VAR scope and check to see if there's anything in there you didn't expect.
    getting at the VAR scope is not as straight forward as with other scopes,
    but this does it:

    <cfdump var="#getPageContext().getActiveFunctionLocalScope()#">

    --
    Adam
    Inspiring
    April 24, 2008
    Ok, so I added some code into my CFC that says:
    cffunction name="getinfo"
    hint="Gets all tournament info from the database" returntype="date"
    output="no">

    And :
    <cfset var testResult=#NewTournDate#>
    <cfreturn testResult />

    And to call the CFC:
    <cfinvoke component="components.duplicate2" method="getinfo"
    returnvariable="testDate">

    And to display:
    <cfoutput>#testDate#</cfoutput>

    And I'm getting:
    Variable TESTDATE is undefined.



    "Azadi" <azadi@sabai-dee.com> wrote in message
    news:fuq541$agq$1@forums.macromedia.com...
    > <cfinvoke component="..." method="..." RETURNVARIABLE="somenamehere">
    > <cfoutput>#somenamehere#</cfoutput>
    >
    > Azadi Saryev
    > Sabai-dee.com
    > http://www.sabai-dee.com/


    BKBK
    Community Expert
    Community Expert
    April 24, 2008
    <cfset returnVar=createobject("component","component_path").calcDate(your_valid_id)>
    <cfoutput>#returnVar#</cfoutput>
    Inspiring
    April 24, 2008
    <cfinvoke component="..." method="..." RETURNVARIABLE="somenamehere">
    <cfoutput>#somenamehere#</cfoutput>

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    April 24, 2008
    Well, the problem is that I'm not sure how to get the <cfoutput> to be
    displayed on the screen if that info is being called by <cfinvoke>.

    So if that code is running in a CFC, how can I display whats in that
    <cfoutput>#calcDate(your_valid_id)#</cfoutput>?

    "BKBK" <webforumsuser@macromedia.com> wrote in message
    news:fuouir$114$1@forums.macromedia.com...
    > My last post is not about the ID, it is about the return value of the
    > function. What does this give you
    >
    > <cfoutput>#calcDate(your_valid_id)#</cfoutput>?
    >
    >
    >


    BKBK
    Community Expert
    Community Expert
    April 24, 2008
    My last post is not about the ID, it is about the return value of the function. What does this give you

    <cfoutput>#calcDate(your_valid_id)#</cfoutput>?


    Inspiring
    April 23, 2008
    Well, its not, we're not that far along yet (lower numbers....).

    I know that the number being passed is a good ID, and that when the function
    gets the ID it looks up the ID in the database and pulls its info from the
    timestamp field.......

    "BKBK" <webforumsuser@macromedia.com> wrote in message
    news:fuo2lb$2v4$1@forums.macromedia.com...
    > You could do some tests, for example
    >
    > <cfoutput>#calcDate(177)#</cfoutput>.
    >
    > I have assumed that 177 is an appropriate id.
    >
    >


    BKBK
    Community Expert
    Community Expert
    April 23, 2008
    You could do some tests, for example

    <cfoutput>#calcDate(177)#</cfoutput>.

    I have assumed that 177 is an appropriate id.