Skip site navigation (1) Skip section navigation (2)

Re: inverse of "day of year"

From: Dana Hudes <dhudes(at)tcp-ip(dot)info>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: inverse of "day of year"
Date: 2004-03-22 15:56:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
If you have the option to handle the date manipulation in Perl
use the DateTime modules. Also see Date::Calc.
A considerable amount of effort has been expended dealing with all
the nitty-gritty of time manipulation.
Use those modules , get your new date or time interval and
feed that to the dbms with a straightforward inequality .
Don't try to do date arithmetic in sql if you can avoid it you'll
run afoul of something or other.

On Mon, 22 Mar 2004, Bruno Wolff III wrote:

> On Mon, Mar 22, 2004 at 10:14:40 -0300,
>   Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> wrote:
> > 
> > Any thoughts on how this could affect date manipulation?
> This is consistant with what I explained about the behavior when adding
> a month results in a day in a month past the end of the new month.
> What do you expect to have happen here?
> > mydb=> select '29/2/2004'::date + ((2005 - date_part('year', now())::int) || 
> > 'years')::interval;
> >       ?column?
> > ---------------------
> >  2005-02-28 00:00:00
> > 
> > AFAIKS with other dates this works OK. :-)
> The real issue with intervals is that how they work in unusual cases is
> not documented. The behavior could change in a future version without
> much fanfare.
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to


pgsql-sql by date

Next:From: Erik ThieleDate: 2004-03-22 16:21:21
Subject: Re: special integrity constraints
Previous:From: Bruno Wolff IIIDate: 2004-03-22 15:18:10
Subject: Re: inverse of "day of year"

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group