@@ -2415,6 +2415,26 @@ current_date()
24152415 SELECT current_date ();
24162416```
24172417
2418+ #### Example
2419+
2420+ ``` sql
2421+ > SELECT current_date ();
2422+ + -- --------------+
2423+ | current_date () |
2424+ + -- --------------+
2425+ | 2024 - 12 - 23 |
2426+ + -- --------------+
2427+
2428+ -- The current date is based on the session time zone (UTC by default)
2429+ > SET datafusion .execution .time_zone = ' Asia/Tokyo' ;
2430+ > SELECT current_date ();
2431+ + -- --------------+
2432+ | current_date () |
2433+ + -- --------------+
2434+ | 2024 - 12 - 24 |
2435+ + -- --------------+
2436+ ```
2437+
24182438#### Aliases
24192439
24202440- today
@@ -2433,6 +2453,26 @@ current_time()
24332453 SELECT current_time ();
24342454```
24352455
2456+ #### Example
2457+
2458+ ``` sql
2459+ > SELECT current_time ();
2460+ + -- ------------------+
2461+ | current_time () |
2462+ + -- ------------------+
2463+ | 06 :30 :00 .123456789 |
2464+ + -- ------------------+
2465+
2466+ -- The current time is based on the session time zone (UTC by default)
2467+ > SET datafusion .execution .time_zone = ' Asia/Tokyo' ;
2468+ > SELECT current_time ();
2469+ + -- ------------------+
2470+ | current_time () |
2471+ + -- ------------------+
2472+ | 15 :30 :00 .123456789 |
2473+ + -- ------------------+
2474+ ```
2475+
24362476### ` current_timestamp `
24372477
24382478_ Alias of [ now] ( #now ) ._
@@ -2537,6 +2577,23 @@ date_part(part, expression)
25372577
25382578- ** expression** : Time expression to operate on. Can be a constant, column, or function.
25392579
2580+ #### Example
2581+
2582+ ``` sql
2583+ > SELECT date_part(' year' , ' 2024-05-01T00:00:00' );
2584+ + -- ---------------------------------------------------+
2585+ | date_part(Utf8(" year" ),Utf8(" 2024-05-01T00:00:00" )) |
2586+ + -- ---------------------------------------------------+
2587+ | 2024 |
2588+ + -- ---------------------------------------------------+
2589+ > SELECT extract(day FROM timestamp ' 2024-05-01T00:00:00' );
2590+ + -- --------------------------------------------------+
2591+ | date_part(Utf8(" DAY" ),Utf8(" 2024-05-01T00:00:00" )) |
2592+ + -- --------------------------------------------------+
2593+ | 1 |
2594+ + -- --------------------------------------------------+
2595+ ```
2596+
25402597#### Alternative Syntax
25412598
25422599``` sql
@@ -2582,6 +2639,23 @@ date_trunc(precision, expression)
25822639
25832640- ** expression** : Timestamp or time expression to operate on. Can be a constant, column, or function.
25842641
2642+ #### Example
2643+
2644+ ``` sql
2645+ > SELECT date_trunc(' month' , ' 2024-05-15T10:30:00' );
2646+ + -- ---------------------------------------------+
2647+ | date_trunc(Utf8(" month" ),Utf8(" 2024-05-15T10:30:00" )) |
2648+ + -- ---------------------------------------------+
2649+ | 2024 - 05 - 01T00:00 :00 |
2650+ + -- ---------------------------------------------+
2651+ > SELECT date_trunc(' hour' , ' 2024-05-15T10:30:00' );
2652+ + -- --------------------------------------------+
2653+ | date_trunc(Utf8(" hour" ),Utf8(" 2024-05-15T10:30:00" )) |
2654+ + -- --------------------------------------------+
2655+ | 2024 - 05 - 15T10:00 :00 |
2656+ + -- --------------------------------------------+
2657+ ```
2658+
25852659#### Aliases
25862660
25872661- datetrunc
@@ -2694,6 +2768,26 @@ The `now()` return value is determined at query time and will return the same ti
26942768now()
26952769```
26962770
2771+ #### Example
2772+
2773+ ``` sql
2774+ > SELECT now();
2775+ + -- --------------------------------+
2776+ | now() |
2777+ + -- --------------------------------+
2778+ | 2024 - 12 - 23T06:30 :00 .123456789 |
2779+ + -- --------------------------------+
2780+
2781+ -- The timezone of the returned timestamp depends on the session time zone
2782+ > SET datafusion .execution .time_zone = ' America/New_York' ;
2783+ > SELECT now();
2784+ + -- ------------------------------------+
2785+ | now() |
2786+ + -- ------------------------------------+
2787+ | 2024 - 12 - 23T01:30 :00 .123456789 - 05 :00 |
2788+ + -- ------------------------------------+
2789+ ```
2790+
26972791#### Aliases
26982792
26992793- current_timestamp
0 commit comments