For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > December 2006 > Date::Calc and postgres timestamp









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Date::Calc and postgres timestamp
jeff_jones_101@yahoo.com

2006-12-27, 7:01 pm

Dear all,

I'd little a little hint on date comparison using Date::Cal module.

I take the first date from a postgres db where the field is declared
as:
created | timestamp(6) without time zone |
Selecting through DBI I receive a date in the form of
2006-12-14 16:08:39

The second one is a a Date::Calc

my ($y,$m,$d,$H,$M,$S) = Add_Delta_DHMS(Today_and_Now(),120,0,0,0
);

I grasp a bit in Date:Calc documentation but I've not found a way to
convert the first in a delta vector, which I think it is the only way
Date:Calc could compare the the two dates.

How can I compare these two date type ?

Thanks

Jim Gibson

2006-12-27, 7:01 pm

In article <1167231038.943941.243690@f1g2000cwa.googlegroups.com>,
<jeff_jones_101@yahoo.com> wrote:

> Dear all,
>
> I'd little a little hint on date comparison using Date::Cal module.
>
> I take the first date from a postgres db where the field is declared
> as:
> created | timestamp(6) without time zone |
> Selecting through DBI I receive a date in the form of
> 2006-12-14 16:08:39
>
> The second one is a a Date::Calc
>
> my ($y,$m,$d,$H,$M,$S) = Add_Delta_DHMS(Today_and_Now(),120,0,0,0
);
>
> I grasp a bit in Date:Calc documentation but I've not found a way to
> convert the first in a delta vector, which I think it is the only way
> Date:Calc could compare the the two dates.
>
> How can I compare these two date type ?


I haven't used Date::Calc, but from the documentation it appears that
it does not work with a date/time value, but with just the individual
parts (year, month, day, etc.).

You can break a date/time in the form "2006-12-14 16:08:39" into its
individual parts with the split function:

perl -e '$x=q(2006-12-14 16:08:39);@a=split(/[ :-]/,$x);print"@a\n";'
2006 12 14 16 08 39

The FAQ also recommends Date::Manip and DateTime modules, which do
create scalars representing date/time values.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com