agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: AlexK <alkuzo@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Selecting consecutive dates as integers in yyyymmdd format
Date: Wed, 19 Feb 2014 14:18:13 -0800 (PST)
Message-ID: <1392848293186-5792815.post@n5.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

The following code gets the job done, but I am wondering if there is a
simpler/cleaner way? 

WITH start_date AS(SELECT DATE '2014-02-18' AS start_date)
select CAST( to_char(start_date + INTERVAL '1d'*i,'YYYYMMDD') AS INT) AS
end_range 
from generate_series(1,100) AS i CROSS JOIN start_date;

end_range
integer

20140219
20140220
20140221
20140222
20140223
20140224
20140225
20140226
20140227
20140228
20140301
20140302
(snip)



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Selecting-consecutive-dates-as-integers-in-yyyymmdd-format-t...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (2+ messages)  latest in thread

Message-ID: <1392848293186-5792815.post@n5.nabble.com>
Permalink:  ../1392848293186-5792815.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1392848293186-5792815.post@n5.nabble.com

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: alkuzo@gmail.com
  Subject: Re: Selecting consecutive dates as integers in yyyymmdd format
  In-Reply-To: <1392848293186-5792815.post@n5.nabble.com>

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

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