Spec-Zone.ru › ColdFusion

createTimespan

Returns a value that defines a time period, represented by a numeric (double) where 1 equals 1 day. You can add or subtract it from other date/time objects and use it with the cachedWithin attribute of cfquery.

createTimespan(days, hours, minutes, seconds) → returns numeric

  • CF
  • Lucee
  • BL 1.0.0+
  • Argument Reference

    days numeric
    Required

    The number of days ranging from 0 to 32768

    hours numeric
    Required

    The number of hours

    minutes numeric
    Required

    The number of minutes

    seconds numeric
    Required

    The number of seconds

    Examples
    Sample code invoking the createTimespan function

    Use of createTimespan in a cfquery

    The createTimespan function is useful in the cachedwithin attribute of cfquery.

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

    The createTimespan function returns a numeric value

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

    createTimespan(0, 6, 0, 0)

    Expected Result: 0.25

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

    Expected Result: 03-Jan-17

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/createtimespan

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API