This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new f9ef488aec Add to_unixtime function to scalar functions doc (#10620)
f9ef488aec is described below

commit f9ef488aecca9a445a5110079fb2f295c80a8850
Author: Bruce Ritchie <[email protected]>
AuthorDate: Wed May 22 13:50:09 2024 -0400

    Add to_unixtime function to scalar functions doc (#10620)
---
 docs/source/user-guide/sql/scalar_functions.md | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/docs/source/user-guide/sql/scalar_functions.md 
b/docs/source/user-guide/sql/scalar_functions.md
index f0feb9ec21..625e0d95b5 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -1464,6 +1464,7 @@ position(substr in origstr)
 - [to_timestamp_seconds](#to_timestamp_seconds)
 - [to_timestamp_nanos](#to_timestamp_nanos)
 - [from_unixtime](#from_unixtime)
+- [to_unixtime](#to_unixtime)
 
 ### `now`
 
@@ -1964,6 +1965,41 @@ from_unixtime(expression)
 - **expression**: Expression to operate on.
   Can be a constant, column, or function, and any combination of arithmetic 
operators.
 
+### `to_unixtime`
+
+Converts a value to seconds since the unix epoch (`1970-01-01T00:00:00Z`).
+Supports strings, dates, timestamps and double types as input.
+Strings are parsed as RFC3339 (e.g. '2023-07-20T05:44:00') if no [Chrono 
formats] are provided.
+
+```
+to_unixtime(expression[, ..., format_n])
+```
+
+#### Arguments
+
+- **expression**: Expression to operate on.
+  Can be a constant, column, or function, and any combination of arithmetic 
operators.
+- **format_n**: Optional [Chrono format] strings to use to parse the 
expression. Formats will be tried in the order
+  they appear with the first successful one being returned. If none of the 
formats successfully parse the expression
+  an error will be returned.
+
+#### Example
+
+```
+> select to_unixtime('2020-09-08T12:00:00+00:00');
++------------------------------------------------+
+| to_unixtime(Utf8("2020-09-08T12:00:00+00:00")) |
++------------------------------------------------+
+| 1599566400                                     |
++------------------------------------------------+
+> select to_unixtime('01-14-2023 01:01:30+05:30', '%q', '%d-%m-%Y %H/%M/%S', 
'%+', '%m-%d-%Y %H:%M:%S%#z');
++-----------------------------------------------------------------------------------------------------------------------------+
+| to_unixtime(Utf8("01-14-2023 01:01:30+05:30"),Utf8("%q"),Utf8("%d-%m-%Y 
%H/%M/%S"),Utf8("%+"),Utf8("%m-%d-%Y %H:%M:%S%#z")) |
++-----------------------------------------------------------------------------------------------------------------------------+
+| 1673638290                                                                   
                                               |
++-----------------------------------------------------------------------------------------------------------------------------+
+```
+
 ## Array Functions
 
 - [array_append](#array_append)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to