| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | hodges(at)xprt(dot)net |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: date comparison between perl and postgres |
| Date: | 2004-01-12 15:39:59 |
| Message-ID: | 20040112153959.GB21007@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Sun, Jan 11, 2004 at 09:27:09 -0800,
hodges(at)xprt(dot)net wrote:
> > Is there a way to have perl return day of the month as
> > a 2 digit string or some code to automaticly pad it?
> > I am using
> >
> > # Get current time and date
> > ($mday,$mon,$year)=(localtime(time + (24*60*60)))[3..5];
> > $mon ++;
> > $year +=1900;
> > $dstr1 = "$year-$mon-$mday";
> >
> > Thanks for any ideas,
You could use sprintf in perl to generate the date string.
If you are actually doing the compare in postgres it might be better
to just get the time in seconds since the epoch and cast that to abstime
and then to date.
For example:
area=> select 1073921933::abstime::date;
date
------------
2004-01-12
(1 row)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bill Moseley | 2004-01-12 15:42:41 | Re: Connect error |
| Previous Message | Russell Shaw | 2004-01-12 15:33:20 | Connect error |