ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Deployments
    • Cloud
    • Server
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
    • Supported Driver Versions
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Install
Search Ask AI
ScyllaDB Docs ScyllaDB Node.js Driver API Reference Modules types Duration

Duration¶

types~Duration(months, days, nanoseconds)

Represents a duration. A duration stores separately months, days, and seconds due to the fact that the number of days in a month varies, and a day can have 23 or 25 hours if a daylight saving is involved.

Constructor¶

new Duration(months, days, nanoseconds)

Creates a new instance of Duration.

Parameters:
Name Type Description
months Number

The number of months.

days Number

The number of days.

nanoseconds Number | Long | BigInt

The number of nanoseconds.

Source

types/duration.js, line 40

Members¶

(readonly) days :Number

Gets the number of days

Type:
  • Number

Source

types/duration.js, line 133

(readonly) months :Number

Gets the number of months

Type:
  • Number

Source

types/duration.js, line 120

(readonly) nanoseconds :Long

Gets the number of nanoseconds

Type:
  • Long

Source

types/duration.js, line 146

Methods¶

toBuffer() → {Buffer}

Serializes the duration and returns the representation of the value in bytes.

Source

types/duration.js, line 158

Returns:
Type
Buffer

toString() → {string}

Returns the string representation of the value.

Source

types/duration.js, line 186

Returns:
Type
string

(static) fromBuffer(buffer) → {Duration}

Creates a new Duration instance from the binary representation of the value.

Parameters:
Name Type Description
buffer Buffer

Source

types/duration.js, line 229

Returns:
Type
Duration

(package, static) fromRust(arg) → {Duration}

Get duration from rust object. Not intended to be exposed in the API

Parameters:
Name Type Description
arg rust.DurationWrapper

Source

types/duration.js, line 110

Returns:
Type
Duration

(static) fromString(input) → {Duration}

Creates a new Duration instance from the string representation of the value.

Parameters:
Name Type Description
input String

Accepted formats:

  • multiple digits followed by a time unit like: 12h30m where the time unit can be:
    • y: years
    • mo: months
    • w: weeks
    • d: days
    • h: hours
    • m: minutes
    • s: seconds
    • ms: milliseconds
    • us or µs: microseconds
    • ns: nanoseconds
  • ISO 8601 format: P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W
  • ISO 8601 alternative format: P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]

Duration can be made negative by adding - at the beginning of the input

Source

types/duration.js, line 264

Returns:
Type
Duration
Examples

From formatted string

let date = fromString("4mo7d20ns");  // 1 month, 7 days, 20 nanoseconds

From ISO 8601

let date = fromString("P2DT5M");     // 2 days, 5 minutes

Was this page helpful?

PREVIOUS
types
NEXT
InetAddress
  • Create an issue
  • Edit this page

On this page

  • Duration
    • Constructor
    • Members
    • Methods
ScyllaDB Node.js Driver
Search Ask AI
  • main
    • main
  • API Reference
    • Modules
      • auth
        • AuthProvider
        • Authenticator
        • PlainTextAuthProvider
      • concurrent
      • datastax
      • errors
        • ArgumentError
        • AuthenticationError
        • BusyConnectionError
        • DriverInternalError
        • NoHostAvailableError
        • NotSupportedError
        • OperationTimedOutError
        • ResponseError
      • geometry
      • mapping
        • DefaultTableMappings
        • Mapper
        • ModelBatchItem
        • ModelMapper
        • Result
        • UnderscoreCqlToCamelCaseMappings
        • TableMappings
      • metadata
        • Aggregate
        • ClientState
        • ColumnMetadata
        • Index
        • KeyspaceMetadata
        • MaterializedView
        • Metadata
        • SchemaFunction
        • Strategy
        • TableMetadata
        • UdtField
        • UserDefinedType
      • metrics
        • DefaultMetrics
        • ClientMetrics
      • policies
        • addressResolution
          • AddressTranslator
          • EC2MultiRegionTranslator
          • MappingAddressTranslator
        • loadBalancing
          • AllowListPolicy
          • DCAwareRoundRobinPolicy
          • DefaultLoadBalancingPolicy
          • LegacyDefaultLoadBalancingPolicy
          • LoadBalancingConfig
          • LoadBalancingPolicy
          • RoundRobinPolicy
          • TokenAwarePolicy
        • reconnection
          • ConstantReconnectionPolicy
          • ExponentialReconnectionPolicy
          • ReconnectionPolicy
        • retry
          • FallthroughRetryPolicy
          • RetryPolicy
        • speculativeExecution
          • ConstantSpeculativeExecutionPolicy
          • NoSpeculativeExecutionPolicy
          • SpeculativeExecutionPolicy
        • timestampGeneration
          • MonotonicTimestampGenerator
          • TimestampGenerator
      • tracker
        • RequestLogger
        • RequestTracker
      • types
        • Duration
        • InetAddress
        • Integer
        • LocalDate
        • Long
        • ResultSet
        • ResultStream
        • Row
        • TimeUuid
        • Vector
    • Classes
      • AddressResolver
      • ByteOrderedToken
      • Client
      • Encoder
      • EncoderMembers
      • ExecutionOptions
      • ExecutionProfile
      • FrameReader
      • HashSet
      • Host
      • HostMap
      • LineString
      • Murmur3Token
      • Point
      • Polygon
      • PreparedInfo
      • RandomToken
      • SslOptions
      • Token
      • TokenRange
    • Interfaces
    • Events
    • Global Functions and Constants
Docs Tutorials University Contact Us About Us
© 2026 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 14 May 2026.
Powered by Sphinx 9.1.0 & ScyllaDB Theme 1.9.2