dfr as-datetime
for dataframe> dfr as-datetime {flags} (format)
--not-exact, -n
: the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01)format
: formatting date time stringinput | output |
---|---|
any | any |
Converts string to datetime
> ["2021-12-30 00:00:00""2021-12-31 00:00:00"] |dfr into-df|dfr as-datetime"%Y-%m-%d %H:%M:%S"
╭───┬─────────────╮
│# │ datetime │
├───┼─────────────┤
│0│2yearsago│
│1│2yearsago│
╰───┴─────────────╯
Converts string to datetime with high resolutions
> ["2021-12-30 00:00:00.123456789""2021-12-31 00:00:00.123456789"] |dfr into-df|dfr as-datetime"%Y-%m-%d %H:%M:%S.%9f"
╭───┬─────────────╮
│# │ datetime │
├───┼─────────────┤
│0│2yearsago│
│1│2yearsago│
╰───┴─────────────╯
Format example: "%y/%m/%d %H:%M:%S" => 21/12/31 12:54:98 "%y-%m-%d %H:%M:%S" => 2021-12-31 24:58:01 "%y/%m/%d %H:%M:%S" => 21/12/31 24:58:01 "%y%m%d %H:%M:%S" => 210319 23:58:50 "%Y/%m/%d %H:%M:%S" => 2021/12/31 12:54:98 "%Y-%m-%d %H:%M:%S" => 2021-12-31 24:58:01 "%Y/%m/%d %H:%M:%S" => 2021/12/31 24:58:01 "%Y%m%d %H:%M:%S" => 20210319 23:58:50 "%FT%H:%M:%S" => 2019-04-18T02:45:55 "%FT%H:%M:%S.%6f" => microseconds "%FT%H:%M:%S.%9f" => nanoseconds
Tips: Dataframe commands were not shipped in the official binaries by default, you have to build it with --features=dataframe
flag
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/dfr_as-datetime.html