Calculation/Comparison on Date

S

sam

Hi,

I m wondering whether there is existing perl module provide functions
for calculating date and comparison of two dates.

I need to take a user input date and will subtract it by 1,3,6 or 12
months. As the requirement only care about YYYY-MM, so I will need to
know the form of starting date and ending date (YYYY-MM-DD) after the
substraction. In this case, the starting date should be in the form of
YYYY-MM-01 and ending date is YYYY-MM-28,29,30 or 31.

Thanks
Sam
 
J

jkeen_via_google

sam said:
Hi,

I m wondering whether there is existing perl module provide functions
for calculating date and comparison of two dates.

I need to take a user input date and will subtract it by 1,3,6 or 12
months. As the requirement only care about YYYY-MM, so I will need to
know the form of starting date and ending date (YYYY-MM-DD) after the
substraction. In this case, the starting date should be in the form of
YYYY-MM-01 and ending date is YYYY-MM-28,29,30 or 31.

CPAN is your friend. See the Date::* and DateTime::* namespaces. My
personal favorite is Date::Calc
(http://cpan.uwinnipeg.ca/module/Date::Calc). For your task, I would
look at the Date::Calc functions whose names begin with Delta_ or
Add_Delta_.

Jim Keenan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top