Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Number of Days Between 2 Dates.
I have the current releace of ActiveState for Win32.

I'm  by the shear number of time and date modules and exactly what
they are capable of doing. I need help calculating the number of days
(including wends) between two dates. All dates are in the format of
mm/dd/yyyy. This format can be changed if needed.

What module is best to use and what is the format of the function. Thanks.

Fred


Report this thread to moderator Post Follow-up to this message
Old Post
Fred Goldberg
09-29-04 02:27 AM


Re: Number of Days Between 2 Dates.
Fred Goldberg wrote:

> I have the current releace of ActiveState for Win32.
>
> I'm  by the shear number of time and date modules and exactly what
> they are capable of doing. I need help calculating the number of days
> (including wends) between two dates. All dates are in the format of
> mm/dd/yyyy. This format can be changed if needed.
>
> What module is best to use and what is the format of the function. Thanks.

Time::Local should do the trick

The docs are pretty straight forward.  timelocal is most likely the
function you're after.

B.



Report this thread to moderator Post Follow-up to this message
Old Post
Brendon Caligari
09-29-04 02:27 AM


Re: Number of Days Between 2 Dates.
Fred Goldberg wrote:
> I'm  by the shear number of time and date modules and
> exactly what they are capable of doing. I need help calculating the
> number of days (including wends) between two dates. All dates
> are in the format of mm/dd/yyyy. This format can be changed if
> needed.
>
> What module is best to use

Probably Date::Calc.

> and what is the format of the function.

See the docs for the module. Reading the docs doesn't confuse you,
does it?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-29-04 02:27 AM


Re: Number of Days Between 2 Dates.
Brendon Caligari wrote:
> Fred Goldberg wrote: 
>
> Time::Local should do the trick

Well, I agree, even if I suggested Date::Calc in another message.
Reminds me of another thread in this group:
http://groups.google.com/groups?sel...40uni-berlin.de

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
09-29-04 02:27 AM


Re: Number of Days Between 2 Dates.
Brendon Caligari (bcaligari@nospam.fireforged.com) wrote on MMMMXLVI
September MCMXCIII in <URL:news:4159d38b$0$94918$bed64819@news.gradwell.net>
:
__  Fred Goldberg wrote:
__
__ > I have the current releace of ActiveState for Win32.
__ >
__ > I'm  by the shear number of time and date modules and exactly w
hat
__ > they are capable of doing. I need help calculating the number of days
__ > (including wends) between two dates. All dates are in the format of
__ > mm/dd/yyyy. This format can be changed if needed.
__ >
__ > What module is best to use and what is the format of the function. Than
ks.
__
__  Time::Local should do the trick


Well, it can do the trick, and so can Math::BigInt.

__  The docs are pretty straight forward.  timelocal is most likely the
__  function you're after.

Really? If I look at the pretty straight forward docs, the docs tell me
that timelocal takes a date/time value which is broken down in seconds,
minutes, hours, day of month, month and year (with the month counted
as January 0, February 1, etc, and some complicated rules on what the
year should be), and returns an integer giving us seconds
since January 1, 1970 GMT. (It falsely says midnight, but it's actually
about half a minute past midnight, due to leap seconds).

It takes some extra work to use this to calculate the difference between
two dates correctly. The docs also say it may not work for dates before
Jan 1, 1970. Nor will it, according to the docs, work on most systems
for dates before Dec 1901, or after Jan 2038.

I'd say that while it's not impossible to use Time::Local, it's awkward,
and will only work for a limited set of dates.

Date::Calc on the other hand has a function, Delta_Days() that does
exactly what the OP wants.


Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop}
;
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> (
)
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> (
)

Report this thread to moderator Post Follow-up to this message
Old Post
Abigail
09-29-04 02:27 AM


Re: Number of Days Between 2 Dates.
Fred Goldberg wrote:

> I have the current releace of ActiveState for Win32.
>
> I'm  by the shear number of time and date modules and exactly what
> they are capable of doing. I need help calculating the number of days
> (including wends) between two dates. All dates are in the format of
> mm/dd/yyyy. This format can be changed if needed.
>
> What module is best to use and what is the format of the function. Thanks.
>
> Fred
>
As other posters have stated, try Date::Calc.  I use it in production
code at work.  IIRC, ActiveState has a ppm for Date::Calc which means
that you don't need to have an installed C-compiler to install it.  And
DeltaDays is indeed the function you want to use.

jimk

Report this thread to moderator Post Follow-up to this message
Old Post
Jim Keenan
09-29-04 02:27 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:37 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.