Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[mv] Comparing Dates



******    message to minivend-users from "Cameron B. Prince" <cbp@InternetExpertsLLC.com>     ******

Hi list,

I need to find out if a date in the database is before or after the current
date.

I have my dates stored in this format: 06/12/00

I thought this would be a fairly common function, but after much searching,
I haven't had any luck in finding any such code. I went ahead and started
coding the function myself in perl, but I have gotten stuck with exactly
what to do next.

What this code should do is return a value (1 or anything) if the scratch
status is pending and the due date is before the current date.

The way I started, it looks like it's going to be a huge hunk of code and I
am wondering if there's a better way to do this.

Also, would code like this be better placed in a global sub, user tag or
embedded in the page?

Here's the code I have so far:

[seti past_due]
[perl global=1]

my $status = '[scratch status]';
my @current_date = split /\//, $Scratch->{current_date};
my $current_month = @current_date[0];
my $current_day = @current_date[1];
my $current_year = @current_date[2];
my @due_date = split /\//, $Scratch->{due_date};
my $due_month = @due_date[0];
my $due_day = @due_date[1];
my $due_year = @due_date[2];

if ($status == pending)


	if ($current_year != $due_year)


		$v1 = 1;
		}
	if ($current_year >= $due_year)


		$v2 = 1;
		}
	if ($current_year <= $due_year)


	 	$v3 = 1;
		}
	if ($current_day != $due_day)


		$v4 = 1;
		}
	if ($current_day >= $due_day)


		$v5 = 1;
		}
	if ($current_day <= $due_day)


	 	$v6 = 1;
		}
	if ($current_month != $due_month)


		$v7 = 1;
		}
	if ($current_month >= $due_month)


		$v8 = 1;
		}
	if ($current_month <= $due_month)
		{
		$v9 = 1;
		}
     }
else
     {
	 return;
     }

[/perl]
[/seti]

I had planned on somehow implementing a final if that would evaluate the
$v's and set the output accordingly.

Any help would be greatly appreciated. Please excuse my ignorance, I am just
learning with Perl.


Thanks,

Cameron

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: