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

- 日本語

# 7.15.23. `time_classify_day_of_week`

## 7.15.23.1. Summary

New in version 8.0.5.

It returns the day of the week of the given time as a `UInt8` value. `0` is Sunday. `6` is Saturday.

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_of_week(time)

## 7.15.23.3. Usage

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

Execution example:

    plugin_register functions/time
    # [[0, 1337566253.89858, 0.000355720520019531], true]

Here is a schema definition and sample data.

Sample schema:

Execution example:

    table_create  Memos TABLE_HASH_KEY ShortText
    # [[0, 1337566253.89858, 0.000355720520019531], true]
    column_create Memos created_at COLUMN_SCALAR Time
    # [[0, 1337566253.89858, 0.000355720520019531], true]

Sample data:

Execution example:

    load --table Memos
    [
    {"_key": "Sunday",    "created_at": "2018-07-01 00:00:00"},
    {"_key": "Monday",    "created_at": "2018-07-02 00:00:00"},
    {"_key": "Tuesday",   "created_at": "2018-07-03 00:00:00"},
    {"_key": "Wednesday", "created_at": "2018-07-04 00:00:00"},
    {"_key": "Thursday",  "created_at": "2018-07-05 00:00:00"},
    {"_key": "Friday",    "created_at": "2018-07-06 00:00:00"},
    {"_key": "Saturday",  "created_at": "2018-07-07 00:00:00"}
    ]
    # [[0, 1337566253.89858, 0.000355720520019531], 7]

Here is a simple usage of `time_classify_day_of_week`:

Execution example:

    select \
      --table Memos \
      --output_columns '_key, time_classify_day_of_week(created_at)'
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         7
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "time_classify_day_of_week",
    #           null
    #         ]
    #       ],
    #       [
    #         "Sunday",
    #         0
    #       ],
    #       [
    #         "Monday",
    #         1
    #       ],
    #       [
    #         "Tuesday",
    #         2
    #       ],
    #       [
    #         "Wednesday",
    #         3
    #       ],
    #       [
    #         "Thursday",
    #         4
    #       ],
    #       [
    #         "Friday",
    #         5
    #       ],
    #       [
    #         "Saturday",
    #         6
    #       ]
    #     ]
    #   ]
    # ]

It returns `0` for Sunday, `1` for Monday, … and `6` for Saturday.

## 7.15.23.4. Return value

The day of the week as `UInt8`. Here are available values:

Value | The day of the week
--- | ---
`0` | Sunday
`1` | Monday
`2` | Tuesday
`3` | Wednesday
`4` | Thursday
`5` | Friday
`6` | Saturday