pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Márcio A. Sepp <marcio@zyontecnologia.com.br>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: RES: help with generation_series in pg10
Date: Tue, 9 Jan 2018 13:23:57 -0300
Message-ID: <20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql> (raw)
In-Reply-To: <00ee01d38964$f7bfbf70$e73f3e50$@com.br>

Márcio A. Sepp wrote:

> > There is a generate_series() variant that can return dates (more
> > precisely, timestamp with time zone).  But what exactly would you like
> > returned?
> 
> In the past i use querys like this to generate some timestamp field:
> select generate_series (1, 10), generate_series('2018-01-01
> 10:00'::timestamp, '2018-01-02 10:00'::timestamp, '10 hours');
> 
> 
> in some case I need to order the timestamp data field and in others I just
> need an interval. So, in some moments an random data already help me and in
> others it is necessary to have both fields aligned.

Maybe something like this

select *
from generate_series(date '2018-01-01 10:00', '2018-01-02 10:00', '10 hours')
   with ordinality;

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (3+ messages)  latest in thread

Message-ID: <20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql>
Permalink:  ../20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@alvh.no-ip.org, marcio@zyontecnologia.com.br
  Subject: Re: help with generation_series in pg10
  In-Reply-To: <20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql>
  References: <00ee01d38964$f7bfbf70$e73f3e50$@com.br> <20180109162357.nyd2jlw3l33rd3hs@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox