CreateTimeSpan

Creates a timespan {@link java.time.Duration}

Method Signature

CreateTimeSpan(days=[numeric], hours=[numeric], minutes=[numeric], seconds=[numeric], milliseconds=[numeric])

Arguments

Argument
Type
Required
Description
Default

days

numeric

true

The number of days in the timespan

hours

numeric

true

The number of hours in the timespan

minutes

numeric

true

The number of minutes in the timespan

seconds

numeric

true

The number of seconds in the timespan

milliseconds

numeric

false

The number of milliseconds in the timespan

0

Examples

Use of createTimespan in a bx:query

The createTimespan function is useful in the cachedwithin attribute of bx:query.

<bx:query name="GetParks" datasource="cfdocexamples" cachedWithin="#createTimespan( 0, 6, 0, 0 )#"> 
 SELECT PARKNAME, REGION, STATE 
 FROM Parks 
 ORDER by ParkName, State 
 </bx:query>

The createTimespan function returns a numeric value

Passing 6 hours, or a quarter of a day returns a double representing 1/4

Run Example

createTimespan( 0, 6, 0, 0 );

Result: PT6H

Adding a date and a timestamp

Instead of using dateAdd you could add a timestamp to a date object

dateFormat( createDate( 2017, 1, 1 ) + createTimespan( 2, 0, 0, 0 ) );

Result: 03-Jan-17

Additional Examples

Run Example

dump( createTimeSpan( 0, 0, 30, 0 ) );
 // 30-minute timespan

Last updated

Was this helpful?