Devuelve el tamaño de la memoria en bytes
memSize({set,spanset}) → integer
SELECT memSize(tstzset '{2001-01-01, 2001-01-02, 2001-01-03}'); -- 48 SELECT memSize(tstzspanset '{[2001-01-01, 2001-01-02], [2001-01-03, 2001-01-04], [2001-01-05, 2001-01-06]}'); -- 112
Devuelve el límite inferior o superior
lower(spans) → base
upper(spans) → base
SELECT lower(tstzspan '[2001-01-01, 2001-01-05)'); -- 2001-01-01 SELECT lower(intspanset '{[1,2],[4,5]}'); -- 1
SELECT lower(tstzspan '[2001-01-01, 2001-01-05)'); -- 2001-01-01 SELECT upper(intspanset '{[1,2],[4,5]}'); -- 6 SELECT lower(tstzspan '[2001-01-01, 2001-01-05)'); -- 2001-01-01 SELECT lower(intspanset '{[1,2],[4,5]}'); -- 1
SELECT upper(floatspan '[20.5, 25.3)'); -- 25.3 SELECT upper(tstzspan '[2001-01-01, 2001-01-05)'); -- 2001-01-05
¿Es el límite inferior or superior inclusivo?
lowerInc(spans) → boolean
upperInc(spans) → boolean
SELECT lowerInc(datespan '[2001-01-01, 2001-01-05)'); -- true SELECT lowerInc(intspanset '{[1,2],[4,5]}'); -- true
SELECT lowerInc(tstzspan '[2001-01-01, 2001-01-05)'); -- true SELECT upperInc(intspanset '{[1,2],[4,5]}'); -- false SELECT upper(floatspan '[20.5, 25.3]'); -- true SELECT upperInc(tstzspan '[2001-01-01, 2001-01-05)'); -- false
Devuelve el ancho del rango como un número de punto flotante
width(numspan) → float
width(numspanset,boundspan=false) → float
Se puede establecer a verdadero un parámetro adicional para calcular el ancho del rango delimitador, ignorando así las posibles brechas de valors
SELECT width(floatspan '[1, 3)'); -- 2 SELECT width(intspanset '{[1,3),[5,7)}'); -- 4 SELECT width(intspanset '{[1,3),[5,7)}', true); -- 6
Devuelve el rango de tiempo
duration({datespan,tstzspan}) → interval
duration({datespanset,tstzspanset},boundspan bool=false) → interval
Se puede establecer a verdadero un parámetro adicional para calcular la duración en el rango delimitador, ignorando así las posibles brechas de tiempo
SELECT duration(datespan '[2001-01-01, 2001-01-03)'); -- 2 days SELECT duration(tstzspanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-05)}'); -- 3 days SELECT duration(tstzspanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-05)}', true); -- 4 days
Devuelve el número de valores o los valores
numValues(set) → integer
getValues(set) → base[]
SELECT numValues(intset '{1,3,5,7}'); -- 4 SELECT getValues(tstzset '{2001-01-01, 2001-01-03, 2001-01-05, 2001-01-07}'); -- {"2001-01-01", "2001-01-03", "2001-01-05", "2001-01-07"}
Devuelve el valor inicial, final o enésimo
startValue(set) → base
endValue(set) → base
valueN(set,integer) → base
SELECT startValue(intset '{1,3,5,7}'); -- 1 SELECT endValue(dateset '{2001-01-01, 2001-01-03, 2001-01-05, 2001-01-07}'); -- 2001-01-07 SELECT valueN(floatset '{1,3,5,7}',2); -- 3
Devuelve el número de rangos o los rangos
numSpans(spanset) → integer
spans(spanset) → span[]
SELECT numSpans(intspanset '{[1,3),[4,5),[6,7)}'); -- 3 SELECT numSpans(datespanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-05), [2001-01-06, 2001-01-07)}'); -- 3 SELECT spans(floatspanset '{[1,3),[4,4],[6,7)}'); -- {"[1,3)","[4,4]","[6,7)"} SELECT spans(tstzspanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-04], [2001-01-05, 2001-01-06)}'); -- {"[2001-01-01,2001-01-03)", "[2001-01-04,2001-01-04]", "[2001-01-05,2001-01-06)"}
Devuelve el rango inicial, final o enésimo
startSpan(spanset) → span
endSpan(spanset) → span
spanN(spanset,integer) → span
SELECT startSpan(intspanset '{[1,3),[4,5),[6,7)}'); -- [1,3) SELECT startSpan(datespanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-05), [2001-01-06, 2001-01-07)}'); -- [2001-01-01,2001-01-03)
SELECT endSpan(floatspanset '{[1,3),[4,4],[6,7)}'); -- [6,7) SELECT endSpan(tstzspanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-04], [2001-01-05, 2001-01-06)}'); -- [2001-01-05,2001-01-06)
SELECT spanN(floatspanset '{[1,3),[4,4],[6,7)}',2); -- [4,4] SELECT spanN(tstzspanset '{[2001-01-01, 2001-01-03), [2001-01-04, 2001-01-04], [2001-01-05, 2001-01-06)}', 2); -- [2001-01-04,2001-01-04]
Devuelve el (number of) different dates
numDates(datespanset) → integer
dates(datespanset) → dateset
SELECT numDates(datespanset '{[2001-01-01, 2001-01-02), [2001-01-03, 2001-01-04)}'); -- 4 SELECT dates(datespanset '{[2001-01-01, 2001-01-02), [2001-01-03, 2001-01-04)}'); -- {2001-01-01, 2001-01-02, 2001-01-03, 2001-01-04}
Devuelve el start, end, or n-th date
startDate(datespanset) → date
endDate(datespanset) → date
dateN(datespanset,integer) → date
The functions do not take into account whether the bounds are inclusive or not.
SELECT startDate(datespanset '{[2001-01-01, 2001-01-02), [2001-01-03, 2001-01-04)}'); -- 2001-01-01 SELECT endDate(datespanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}'); -- 2001-01-05 SELECT dateN(datespanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}', 3); -- 2001-01-05
Devuelve el número o las marcas de tiempo diferentes
numTimestamps(tstzspanset) → integer
timestamps(tstzspanset) → tstzset
SELECT numTimestamps(tstzspanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}'); -- 3 SELECT timestamps(tstzspanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}'); -- {"2001-01-01 00:00:00", "2001-01-03 00:00:00", "2001-01-05 00:00:00"}
Devuelve la marca de tiempo inicial, final, o enésima
startTimestamp(tstzspanset) → timestamptz
endTimestamp(tstzspanset) → timestamptz
timestampN(tstzspanset,integer) → timestamptz
The functions do not take into account whether the bounds are inclusive or not.
SELECT startTimestamp(tstzspanset '{[2001-01-01, 2001-01-02), [2001-01-03, 2001-01-04)}'); -- 2001-01-01 SELECT endTimestamp(tstzspanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}'); -- 2001-01-05 SELECT timestampN(tstzspanset '{[2001-01-01, 2001-01-03), (2001-01-03, 2001-01-05)}', 3); -- 2001-01-05