Re: comparring dates between perl and postgres - Mailing list pgsql-novice

From Frank Way
Subject Re: comparring dates between perl and postgres
Date
Msg-id 20031203203221.83287.qmail@web11608.mail.yahoo.com
Whole thread Raw
In response to comparring dates between perl and postgres  (hodges@xprt.net)
List pgsql-novice
If you are using the Perl Date::Calc module (available from CPAN) you
should be able to plug the year, month, day fields (that you can fairly
easily extract from the date returned by PostgreSQL) into the
Day_of_Year function and get what you want.

Hope this helps,
Frank Way


--- hodges@xprt.net wrote:
> I am getting a field of date type from PostgreSQL and an
> integer that is a number of days (1 to 3).
>
> select date, num_days from table
> $date, $num_days
>
> In my perl script I am getting the current date
>
> #find current date
> ($mday,$mon,$year,$doy)=(localtime(time))[3..5,7];
> $mon ++;
> $year +=1900;
> $today = "$year-$mon-$mday";
>
> I need to test whether $date from PostgreSQL matches
> $today + $num_days.
>
> Can perl extract day of year ($doy) from the Postgres date?
>
> Is there a better way to do this?
>
> Thanks,
> Tom Hodges
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org


=====
Frank Way
E-Mail: fgw_three@yahoo.com

"Place guards on all the roads and keep the troops
from running to the rear..." MG John Buford, 1863

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

pgsql-novice by date:

Previous
From: hodges@xprt.net
Date:
Subject: comparring dates between perl and postgres
Next
From: SaiHertz And Control Systems
Date:
Subject: Re: comparring dates between perl and postgres