liukun4515 commented on a change in pull request #1991:
URL: https://github.com/apache/arrow-datafusion/pull/1991#discussion_r824737187



##########
File path: docs/source/user-guide/sql/datafusion-functions.md
##########
@@ -84,3 +84,31 @@ Note that `CAST(.. AS Timestamp)` converts to Timestamps 
with Nanosecond resolut
 - Other Timestamp() columns or values
 
 Note that `CAST(.. AS Timestamp)` converts to Timestamps with Nanosecond 
resolution; this function is the only way to convert/cast to seconds resolution.
+
+## `EXTRACT, date_part`
+
+`EXTRACT(field FROM source)`
+
+- The extract function retrieves subfields such as year or hour from date/time 
values.
+  source must be a value expression of type timestamp, Data32, Data64 field is 
an identifier that selects what field to extract from the source value.
+  The extract function returns values of type u32.
+  - `year`
+  - `EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 2020`
+  - `month`
+  - `EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 9`
+  - `week`
+  - `EXTRACT(week FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 23`
+  - `day`
+  - `EXTRACT(day FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 8`
+  - `hour`
+  - `EXTRACT(hour FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 12`
+  - `minute`
+  - `EXTRACT(minute FROM to_timestamp('2020-09-08T12:01:00+00:00')) -> 1`
+  - `second`
+  - `EXTRACT(second FROM to_timestamp('2020-09-08T12:00:03+00:00')) -> 3`

Review comment:
       ```suggestion
   
     - `year`: EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 
2020
     - `month`: EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00')) 
-> 9
     - `week`: EXTRACT(week FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 
23
     - `day`: EXTRACT(day FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 8
     - `hour`: EXTRACT(hour FROM to_timestamp('2020-09-08T12:00:00+00:00')) -> 
12
     - `minute`: EXTRACT(minute FROM to_timestamp('2020-09-08T12:01:00+00:00')) 
-> 1
     - `second`: EXTRACT(second FROM to_timestamp('2020-09-08T12:00:03+00:00')) 
-> 3
   
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to