linkend="functions-datetime-current">
- <literal>timeofday()</entry>
- <literal>Wed Feb 21 17:01:13.000126 2001 EST</entry>
+
+
+ In addition to these functions, the SQL OVERLAPS> keyword is
+ supported:
+
+( start1, end1 ) OVERLAPS ( start2, end2 )
+( start1, length1 ) OVERLAPS ( start2, length2 )
+
+ This expression yields true when two time periods (defined by their
+ endpoints) overlap, false when they do not overlap. The endpoints
+ can be specified as pairs of dates, times, or timestamps; or as
+ a date, time, or timestamp followed by an interval.
+
+
+
+SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS
+ (DATE '2001-10-30', DATE '2002-10-30');
+Result: true
+SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS
+ (DATE '2001-10-30', DATE '2002-10-30');
+Result: false
+
+
EXTRACT, date_part
-SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
-Result: 982352320
+SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08');
+Result: 982384720
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
Result: 442800
date_trunc('field', source)
source is a value expression of type
- timestamp. (Values of type date and
- time are cast automatically.)
+ timestamp or interval>.
+ (Values of type date and
+ time are cast automatically, to timestamp or
+ interval> respectively.)
field selects to which precision to
- truncate the time stamp value. The return value is of type
- timestamp with all fields that are less than the
+ truncate the input value. The return value is of type
+ timestamp or interval>
+ with all fields that are less significant than the
selected one set to zero (or one, for day and month).
Examples:
SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
-Result: 2001-02-16 20:00:00+00
+Result: 2001-02-16 20:00:00
SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
-Result: 2001-01-01 00:00:00+00
+Result: 2001-01-01 00:00:00