1
Date and Time Functions
2
=======================
14
For examples of the following, see :doc:`current_time_functions`.
16
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
17
|Name |Return Type |Description |
18
+===================================+=====================================+=================================================================+
19
|current_date |date |Current date |
20
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
21
|current_time |time with time zone |Current time of day |
22
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
23
|current_timestamp |timestamp with time zone |Current date and time (start of current transaction) |
24
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
25
|localtime |time |Current time of day |
26
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
27
|localtimestamp |timestamp |Current date and time (start of current transaction) |
28
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
29
|now() |timestamp with time zone |Current date and time (start of current transaction) |
30
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
31
|statement_timestamp() |timestamp with time zone |Current date and time (start of current statement) |
32
+-----------------------------------+-------------------------------------+-----------------------------------------------------------------+
38
For examples of the following, see :doc:`extract_date_functions`.
40
+--------------------------------+-----------------------+---------------------------------------+
41
|Name |Return Type |Description |
42
+================================+=======================+=======================================+
43
|extract(field from timestamp) |double precision |Get subfield |
44
+--------------------------------+-----------------------+---------------------------------------+
45
|extract(field from interval) |double precision |Get subfield |
46
+--------------------------------+-----------------------+---------------------------------------+
47
|date_part(text, timestamp) |double precision |Get subfield (equivalent to extract) |
48
+--------------------------------+-----------------------+---------------------------------------+
49
|date_part(text, interval) |double precision |Get subfield (equivalent to extract) |
50
+--------------------------------+-----------------------+---------------------------------------+
56
For an example of the following, see :doc:`date_trunc`.
58
+--------------------------------+-----------------------+---------------------------------------+
59
|Name |Return Type |Description |
60
+================================+=======================+=======================================+
61
|date_trunc(text, timestamp) |timestamp |Truncate to specified precision |
62
+--------------------------------+-----------------------+---------------------------------------+