# groonga - An open-source fulltext search engine and column store.

- 日本語

# 7.15.23. `time_classify_day`

## 7.15.23.1. Summary

New in version 6.0.3.

`time_classify_day` rounds time to a day unit.

This rounded `2020-01-30 11:50:11.000000` and `2020-01-30 22:50:11.000000` to `2020-01-30 00:00:00.000000`.

To enable this function, register `functions/time` plugin by the following command:

    plugin_register functions/time

## 7.15.23.2. Syntax

This function has only one parameter:

    time_classify_day(time)

## 7.15.23.3. Usage

Here are a schema definition and sample data to show usage.

You need to register `functions/time` plugin at first:

Here is a schema definition and sample data.

Sample schema:

Execution example:

    table_create Sales TABLE_NO_KEY
    # [[0,1590571264.10303,0.007408380508422852],true]
    column_create Sales name COLUMN_SCALAR ShortText
    # [[0,1590571264.110569,0.003055095672607422],true]
    column_create Sales price COLUMN_SCALAR UInt32
    # [[0,1590571264.113767,0.002195358276367188],true]
    column_create Sales timestamp COLUMN_SCALAR Time
    # [[0,1590571264.116081,0.002101898193359375],true]

Sample data:

Execution example:

    load --table Sales
    [
    {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 11:50:11.000000"},
    {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 10:20:00.000000"},
    {"name": "Orange", "price": "122", "timestamp": "2020-05-01 11:44:12.000001"},
    {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 19:50:23.000020"},
    {"name": "Banana", "price": "88" , "timestamp": "2020-05-01 11:00:02.000000"},
    {"name": "Banana", "price": "88" , "timestamp": "2020-05-01 21:34:12.000001"}
    ]
    # [[0,1590571264.118352,0.001252651214599609],6]

Here is a simple usage of `time_classify_day`:

Execution example:

    select \
      --table Sales \
      --output_columns "name, time_classify_day(timestamp)"
    # [
    #   [
    #     0,
    #     1590136820.452553,
    #     0.0008840560913085938
    #   ],
    #   [
    #     [
    #       [
    #         6
    #       ],
    #       [
    #         [
    #           "name",
    #           "ShortText"
    #         ],
    #         [
    #           "time_classify_day",
    #           null
    #         ]
    #       ],
    #       [
    #         "Apple",
    #         1588258800.0
    #       ],
    #       [
    #         "Apple",
    #         1588258800.0
    #       ],
    #       [
    #         "Orange",
    #         1588258800.0
    #       ],
    #       [
    #         "Apple",
    #         1588258800.0
    #       ],
    #       [
    #         "Banana",
    #         1588258800.0
    #       ],
    #       [
    #         "Banana",
    #         1588258800.0
    #       ]
    #     ]
    #   ]
    # ]

## 7.15.23.4. Parameters

### 7.15.23.4.1. Required parameters

There is only one required parameter.

#### 7.15.23.4.1.1. `column`

Specify a target column.

## 7.15.23.5. Return value

It returns a value that rounded time to a day unit.

The return value is UNIX time.