Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGFT7-0006Sf-U3 for pgsql-sql@arkaria.postgresql.org; Wed, 19 Feb 2014 22:18:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WGFT7-0005gL-EP for pgsql-sql@arkaria.postgresql.org; Wed, 19 Feb 2014 22:18:17 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGFT6-0005gF-Nm for pgsql-sql@postgresql.org; Wed, 19 Feb 2014 22:18:16 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WGFT4-0002Ib-4D for pgsql-sql@postgresql.org; Wed, 19 Feb 2014 22:18:16 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WGFT3-0001lw-6L for pgsql-sql@postgresql.org; Wed, 19 Feb 2014 14:18:13 -0800 Date: Wed, 19 Feb 2014 14:18:13 -0800 (PST) From: AlexK To: pgsql-sql@postgresql.org Message-ID: <1392848293186-5792815.post@n5.nabble.com> Subject: Selecting consecutive dates as integers in yyyymmdd format MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 3.5 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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-tp5792815.html 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