| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: functions_time_classify_day_of_week |
| 5 |
|
| 6 |
``time_classify_day_of_week`` |
| 7 |
============================= |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
.. versionadded:: 8.0.5 |
| 13 |
|
| 14 |
It returns the day of the week of the given time as a ``UInt8`` |
| 15 |
value. ``0`` is Sunday. ``6`` is Saturday. |
| 16 |
|
| 17 |
To enable this function, register ``functions/time`` plugin by the |
| 18 |
following command:: |
| 19 |
|
| 20 |
plugin_register functions/time |
| 21 |
|
| 22 |
.. _time-classify-day-of-the-week-syntax: |
| 23 |
|
| 24 |
Syntax |
| 25 |
------ |
| 26 |
|
| 27 |
This function has only one parameter:: |
| 28 |
|
| 29 |
time_classify_day_of_week(time) |
| 30 |
|
| 31 |
Usage |
| 32 |
----- |
| 33 |
|
| 34 |
You need to register ``functions/time`` plugin at first: |
| 35 |
|
| 36 |
.. groonga-command |
| 37 |
.. include:: ../../example/reference/functions/time_classify_day_of_week/usage_register.log |
| 38 |
.. plugin_register functions/time |
| 39 |
|
| 40 |
Here is a schema definition and sample data. |
| 41 |
|
| 42 |
Sample schema: |
| 43 |
|
| 44 |
.. groonga-command |
| 45 |
.. include:: ../../example/reference/functions/time_classify_day_of_week/usage_setup_schema.log |
| 46 |
.. table_create Memos TABLE_HASH_KEY ShortText |
| 47 |
.. column_create Memos created_at COLUMN_SCALAR Time |
| 48 |
|
| 49 |
Sample data: |
| 50 |
|
| 51 |
.. groonga-command |
| 52 |
.. include:: ../../example/reference/functions/time_classify_day_of_week/usage_setup_data.log |
| 53 |
.. load --table Memos |
| 54 |
.. [ |
| 55 |
.. {"_key": "Sunday", "created_at": "2018-07-01 00:00:00"}, |
| 56 |
.. {"_key": "Monday", "created_at": "2018-07-02 00:00:00"}, |
| 57 |
.. {"_key": "Tuesday", "created_at": "2018-07-03 00:00:00"}, |
| 58 |
.. {"_key": "Wednesday", "created_at": "2018-07-04 00:00:00"}, |
| 59 |
.. {"_key": "Thursday", "created_at": "2018-07-05 00:00:00"}, |
| 60 |
.. {"_key": "Friday", "created_at": "2018-07-06 00:00:00"}, |
| 61 |
.. {"_key": "Saturday", "created_at": "2018-07-07 00:00:00"} |
| 62 |
.. ] |
| 63 |
|
| 64 |
Here is a simple usage of ``time_classify_day_of_week``: |
| 65 |
|
| 66 |
.. groonga-command |
| 67 |
.. include:: ../../example/reference/functions/time_classify_day_of_week/usage_classify.log |
| 68 |
.. select \ |
| 69 |
.. --table Memos \ |
| 70 |
.. --output_columns '_key, time_classify_day_of_week(created_at)' |
| 71 |
|
| 72 |
It returns ``0`` for Sunday, ``1`` for Monday, ... and ``6`` for |
| 73 |
Saturday. |
| 74 |
|
| 75 |
Return value |
| 76 |
------------ |
| 77 |
|
| 78 |
The day of the week as ``UInt8``. Here are available values: |
| 79 |
|
| 80 |
.. list-table:: |
| 81 |
:header-rows: 1 |
| 82 |
|
| 83 |
* - Value |
| 84 |
- The day of the week |
| 85 |
* - ``0`` |
| 86 |
- Sunday |
| 87 |
* - ``1`` |
| 88 |
- Monday |
| 89 |
* - ``2`` |
| 90 |
- Tuesday |
| 91 |
* - ``3`` |
| 92 |
- Wednesday |
| 93 |
* - ``4`` |
| 94 |
- Thursday |
| 95 |
* - ``5`` |
| 96 |
- Friday |
| 97 |
* - ``6`` |
| 98 |
- Saturday |