User Guide Cancel

CreateTimeSpan

 

Description

Creates a date-time object (Java Double). You can add or subtract it from other date-time objects and use it with the cachedWithin attribute of cfquery.

Returns

A date-time object (Java Double).

Category

Date and time functions

Function syntax

CreateTimeSpan(days, hours, minutes, seconds)
CreateTimeSpan(days, hours, minutes, seconds)
CreateTimeSpan(days, hours, minutes, seconds)

See also

CreateDateTimeDateAddDateConvertDefining application-level settings and variables in Defining the application and its event handlers in Application.cfc in the Developing ColdFusion Applications

Parameters

Parameter

Description

days

Integer in the range 0-32768; number of days in time period

hours

Number of hours in time period

minutes

Number of minutes in time period

seconds

Number of seconds in time period

Usage

Creates a date-time object (Java Double) that should be used only to add and subtract from other date-time objects or with the cfquery cachedWithin attribute.If you use the cachedWithin attribute of cfquery, and the original query date falls within the time span you define, cached query data is used. In this case, the CreateTimeSpan function is used to define a period of time from the present backwards. The cachedWithin attribute takes effect only if you enable query caching in the ColdFusion Administrator. For more information, see cfquery.

Example

<cfscript>
hours = 10;
minutes= 09;
seconds= 46;
days = 12;
myTime=CreateTimeSpan(days,hours,minutes,seconds)
writeOutput("Time is : " & myTime)
</cfscript>
<cfscript> hours = 10; minutes= 09; seconds= 46; days = 12; myTime=CreateTimeSpan(days,hours,minutes,seconds) writeOutput("Time is : " & myTime) </cfscript>
<cfscript>
    hours = 10;
    minutes= 09;
    seconds= 46;
    days = 12;
    myTime=CreateTimeSpan(days,hours,minutes,seconds)
    writeOutput("Time is : " & myTime)
</cfscript>

Output

TimeSpan is : 12.4234490741

Get help faster and easier

New user?