From: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Bosco Rama <postgres@boscorama.com>
To: David G. Johnston <david.g.johnston@gmail.com>
To: er.tejaspatel88@gmail.com <er.tejaspatel88@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Fastest way / best practice to calculate "next birthdays"
Date: Fri, 22 May 2015 16:23:19 -0500
Message-ID: <555F9E47.5020003@BlueTreble.com> (raw)
In-Reply-To: <555E0488.1030908@boscorama.com>
References: <fvka82$1b10$1@news.hub.org>
<481DE036.90706@commandprompt.com>
<481DF76D.3060807@theendofthetunnel.de>
<481E9E12.8070208@Sheeky.Biz>
<1431941415888-5849705.post@n5.nabble.com>
<CAKFQuwZLcWw6=T6GU9rF+6DCN6+DSOgZJg1JAgOKLWG6KEUiWA@mail.gmail.com>
<555E0488.1030908@boscorama.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
On 5/21/15 11:15 AM, Bosco Rama wrote:
> You could probably make some of that into a function that accepts a
> timestamptz and generates the two days.
You'll be better off if instead of 2 days it gives you a daterange:
http://www.postgresql.org/docs/9.4/static/rangetypes.html
I don't know about the exact ISO details, but your approach is the
correct one: find the date that the current week started on and then
build a range of [week start, week start + 7 days).
Also, note the use of [ vs ). That is the ONLY correct way to do this if
you're comparing to a timestamp.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
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-performance@postgresql.org
Cc: Jim.Nasby@BlueTreble.com, postgres@boscorama.com, david.g.johnston@gmail.com, er.tejaspatel88@gmail.com
Subject: Re: Fastest way / best practice to calculate "next birthdays"
In-Reply-To: <555F9E47.5020003@BlueTreble.com>
* 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