daft.functions.strftime#
strftime #
strftime(expr: Expression, format: str | None = None) -> Expression
Converts a datetime/date column to a string column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr | Expression | The datetime or date expression to convert. | required |
format | str | None | The format to use for the conversion. If None, defaults to ISO 8601 format. | None |
Note
The format must be a valid datetime format string. (defaults to ISO 8601 format) See: https://docs.rs/chrono/latest/chrono/format/strftime/index.html
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
╭────────────┬─────────────┬────────────────────────────┬─────────────────────┬─────────────────────╮
│ iso_date ┆ custom_date ┆ iso_datetime ┆ iso_datetime_s ┆ custom_datetime │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ String ┆ String ┆ String ┆ String ┆ String │
╞════════════╪═════════════╪════════════════════════════╪═════════════════════╪═════════════════════╡
│ 2023-01-01 ┆ 01/01/2023 ┆ 2023-01-01T12:01:00 ┆ 2023-01-01T12:01:00 ┆ 2023/01/01 12:01:00 │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2023-01-02 ┆ 01/02/2023 ┆ 2023-01-02T12:00:00 ┆ 2023-01-02T12:00:00 ┆ 2023/01/02 12:00:00 │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 2023-01-03 ┆ 01/03/2023 ┆ 2023-01-03T12:00:00.999999 ┆ 2023-01-03T12:00:00 ┆ 2023/01/03 12:00:00 │
╰────────────┴─────────────┴────────────────────────────┴─────────────────────┴─────────────────────╯
(Showing first 3 of 3 rows) Source code in daft/functions/datetime.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |