| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: functions_time_classify_day |
| 5 |
|
| 6 |
``time_classify_day`` |
| 7 |
===================== |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
.. versionadded:: 6.0.3 |
| 13 |
|
| 14 |
``time_classify_day`` rounds time to a day unit. |
| 15 |
|
| 16 |
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``. |
| 17 |
|
| 18 |
To enable this function, register ``functions/time`` plugin by the |
| 19 |
following command:: |
| 20 |
|
| 21 |
plugin_register functions/time |
| 22 |
|
| 23 |
.. _time-classify-day-syntax: |
| 24 |
|
| 25 |
Syntax |
| 26 |
------ |
| 27 |
|
| 28 |
This function has only one parameter:: |
| 29 |
|
| 30 |
time_classify_day(time) |
| 31 |
|
| 32 |
Usage |
| 33 |
----- |
| 34 |
|
| 35 |
Here are a schema definition and sample data to show usage. |
| 36 |
|
| 37 |
You need to register ``functions/time`` plugin at first: |
| 38 |
|
| 39 |
.. groonga-command |
| 40 |
.. include:: ../../example/reference/functions/time_classify_day/usage_register.log |
| 41 |
.. plugin_register functions/time |
| 42 |
|
| 43 |
Here is a schema definition and sample data. |
| 44 |
|
| 45 |
Sample schema: |
| 46 |
|
| 47 |
.. groonga-command |
| 48 |
.. include:: ../../example/reference/functions/time_classify_day/usage_setup_schema.log |
| 49 |
.. table_create Sales TABLE_NO_KEY |
| 50 |
.. column_create Sales name COLUMN_SCALAR ShortText |
| 51 |
.. column_create Sales price COLUMN_SCALAR UInt32 |
| 52 |
.. column_create Sales timestamp COLUMN_SCALAR Time |
| 53 |
|
| 54 |
Sample data: |
| 55 |
|
| 56 |
.. groonga-command |
| 57 |
.. include:: ../../example/reference/functions/time_classify_day/usage_setup_data.log |
| 58 |
.. load --table Sales |
| 59 |
.. [ |
| 60 |
.. {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 11:50:11.000000"}, |
| 61 |
.. {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 10:20:00.000000"}, |
| 62 |
.. {"name": "Orange", "price": "122", "timestamp": "2020-05-01 11:44:12.000001"}, |
| 63 |
.. {"name": "Apple" , "price": "256", "timestamp": "2020-05-01 19:50:23.000020"}, |
| 64 |
.. {"name": "Banana", "price": "88" , "timestamp": "2020-05-01 11:00:02.000000"}, |
| 65 |
.. {"name": "Banana", "price": "88" , "timestamp": "2020-05-01 21:34:12.000001"} |
| 66 |
.. ] |
| 67 |
|
| 68 |
Here is a simple usage of ``time_classify_day``: |
| 69 |
|
| 70 |
.. groonga-command |
| 71 |
.. include:: ../../example/reference/functions/time_classify_day/usage_classify.log |
| 72 |
.. select \ |
| 73 |
.. --table Sales \ |
| 74 |
.. --output_columns 'name, time_classify_day(timestamp)' |
| 75 |
|
| 76 |
Parameters |
| 77 |
---------- |
| 78 |
|
| 79 |
Required parameters |
| 80 |
^^^^^^^^^^^^^^^^^^^ |
| 81 |
|
| 82 |
There is only one required parameter. |
| 83 |
|
| 84 |
``column`` |
| 85 |
"""""""""" |
| 86 |
|
| 87 |
Specify a target column. |
| 88 |
|
| 89 |
Return value |
| 90 |
------------ |
| 91 |
|
| 92 |
It returns a value that rounded time to a day unit. |
| 93 |
|
| 94 |
The return value is UNIX time. |