Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFC return type question

LEGEND ,
Apr 22, 2008 Apr 22, 2008
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>


740
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2008 Apr 22, 2008
Try using returntype = "any"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 22, 2008 Apr 22, 2008
Does the return type date only handle the 'date' and not the date & time????

No, it handles both date and time. See it for yourself with the following, which emulates your code.

<cffunction name="getDate" returntype="date" output="No">
<cfreturn dateAdd('d', 7, createdatetime(2008,4,16,6,41,25))>
</cffunction>

<cfoutput>#getDate()#</cfoutput>

Verify the time values going into the variable FirstOfMonth2MonthsAhead. Is the database column's datatype a date or datetime?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2008 Apr 23, 2008
Its a datetime in the database

"BKBK" <webforumsuser@macromedia.com> wrote in message
news:fumbh8$4rj$1@forums.macromedia.com...
> Does the return type date only handle the 'date' and not the date &
> time????

>
> No, it handles both date and time. See it for yourself with the following,
> which emulates your code.
>
> <cffunction name="getDate" returntype="date" output="No">
> <cfreturn dateAdd('d', 7, createdatetime(2008,4,16,6,41,25))>
> </cffunction>
>
> <cfoutput>#getDate()#</cfoutput>
>
> Verify the time values going into the variable FirstOfMonth2MonthsAhead.
> Is
> the database column's datatype a date or datetime?
>
>
>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2008 Apr 23, 2008
Actually, I take it back, the field is a 'timestamp' in our MySql
database......

"BKBK" <webforumsuser@macromedia.com> wrote in message
news:fumbh8$4rj$1@forums.macromedia.com...
> Does the return type date only handle the 'date' and not the date &
> time????

>
> No, it handles both date and time. See it for yourself with the following,
> which emulates your code.
>
> <cffunction name="getDate" returntype="date" output="No">
> <cfreturn dateAdd('d', 7, createdatetime(2008,4,16,6,41,25))>
> </cffunction>
>
> <cfoutput>#getDate()#</cfoutput>
>
> Verify the time values going into the variable FirstOfMonth2MonthsAhead.
> Is
> the database column's datatype a date or datetime?
>
>
>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2008 Apr 23, 2008
You could do some tests, for example

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

I have assumed that 177 is an appropriate id.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2008 Apr 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.
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2008 Apr 23, 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>?


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2008 Apr 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>?
>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2008 Apr 24, 2008
<cfinvoke component="..." method="..." RETURNVARIABLE="somenamehere">
<cfoutput>#somenamehere#</cfoutput>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2008 Apr 24, 2008
<cfset returnVar=createobject("component","component_path").calcDate(your_valid_id)>
<cfoutput>#returnVar#</cfoutput>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2008 Apr 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/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2008 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2008 Apr 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/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 25, 2008 Apr 25, 2008
LATEST
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>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources