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 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?
    >
    >
    >
    >

    Inspiring
    April 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?
    >
    >
    >
    >

    BKBK
    Community Expert
    Community Expert
    April 23, 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?

    Inspiring
    April 23, 2008
    Try using returntype = "any"