Home Explore Blog CI



nushell

commands/docs/into_duration.md
28d6a59ca8881e48d9ddb0035916146477723b4f0a42149b0000000300000865
---
title: into duration
categories: |
  conversions
version: 0.104.0
conversions: |
  Convert value to duration.
usage: |
  Convert value to duration.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `into duration` for [conversions](/commands/categories/conversions.md)

<div class='command-title'>Convert value to duration.</div>

## Signature

```> into duration {flags} ...rest```

## Flags

 -  `--unit, -u {string}`: Unit to convert number into (will have an effect only with integer input)

## Parameters

 -  `...rest`: For a data structure input, convert data at the given cell paths.


## Input/output types:

| input    | output   |
| -------- | -------- |
| duration | duration |
| float    | duration |
| int      | duration |
| record   | any      |
| string   | duration |
| table    | table    |
## Examples

Convert duration string to duration value
```nu
> '7min' | into duration
7min
```

Convert compound duration string to duration value
```nu
> '1day 2hr 3min 4sec' | into duration
1day 2hr 3min 4sec
```

Convert table of duration strings to table of duration values
```nu
> [[value]; ['1sec'] ['2min'] ['3hr'] ['4day'] ['5wk']] | into duration value
╭───┬───────╮
│ # │ value │
├───┼───────┤
│ 0 │  1sec │
│ 1 │  2min │
│ 2 │   3hr │
│ 3 │  4day │
│ 4 │   5wk │
╰───┴───────╯

```

Convert duration to duration
```nu
> 420sec | into duration
7min
```

Convert a number of ns to duration
```nu
> 1_234_567 | into duration
1ms 234µs 567ns
```

Convert a number of an arbitrary unit to duration
```nu
> 1_234 | into duration --unit ms
1sec 234ms
```

Convert a floating point number of an arbitrary unit to duration
```nu
> 1.234 | into duration --unit sec
1sec 234ms
```

Convert a record to a duration
```nu
> {day: 10, hour: 2, minute: 6, second: 50, sign: '+'} | into duration
1wk 3day 2hr 6min 50sec
```

## Notes
Max duration value is i64::MAX nanoseconds; max duration time unit is wk (weeks).

Chunks
883f4f16 (1st chunk of `commands/docs/into_duration.md`)
Title: into duration Command Documentation
Summary
This document details the `into duration` command in Nushell, which converts various data types (duration, float, int, string, record, and table) into duration values. It explains the command's signature, flags (including the `--unit` flag for specifying the unit of a number), parameters, input/output types, and provides several examples demonstrating its usage. It also notes the maximum duration value and unit.