CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Problem with dates

 



chander1986
Novice

May 23, 2009, 2:41 PM

Post #1 of 1 (208 views)
Problem with dates Can't Post

I am writing a script to find the number of Quarters between 2 dates. For example:
I/P
d1 = 1991 Q1
d2 = 1994 Q3

O/P
13 Quarters

Other way to do it would be to find I such that
d1 + I = d2

Following is the code that i have written so far, but is not working as desired. Can u help me out with where i am going wrong??



Code
$index = 1; 

$i = 1991;
$i_qtr = 1;
if ($i_qtr%4 ==0) {
$i++;
$i_qtr++;
}
else {
$i_qtr++;
}

while(($i < $temp_year)) {

$index++;
$i_qtr++;
if ($i_qtr%4 ==0) {
$i++;
}



}

for (my $p = $temp_qtr ; $p >0 ; $p--) {
$index++;
}

#where temp_year and temp_qtr represents the end date(d2)


Thanks a lot in advance

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives