Akopia Akopia Services

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

Re: [mv] Comparing Dates



******    message to minivend-users from "Michael Schwartz" <michael@panamacom.com>     ******

Hi,
I would recommend saving the date in seconds (unix, started counting in
1970), in a database.
Then compare it.  If you want an expiration of 30 days, then
todays date in seconds (minus) recorded date in seconds in dbase

if its bigger than 2592000  (30 days), then it is expired....when this
condition is made, you can instruct MV to write into the database in a
column of your choice something like '"expired", and specify the searches to
look for not expired items....
i hope i am explaining myself....this has worked for me.

Michael Schwartz

----- Original Message -----
From: Jeff Carnahan <jcarnahan@networq.com>
To: <minivend-users@minivend.com>
Sent: Monday, June 12, 2000 10:04 PM
Subject: RE: [mv] Comparing Dates


> ******    message to minivend-users from "Jeff Carnahan"
<jcarnahan@networq.com>     ******
>
> How about something similar to the following...
>
> The following assumes that if your year is between 00 and 49, you mean
> 2000 - 2049.. 50 - 99 = 1950 - 1999.
>
> use POSIX qw(strftime);
>
> $CompareTo = '06/12/00';  # --> Compare to this date.
>
> ($Month, $Day, $Year) = split(/\//, $CompareTo);
> $Year += ($Year < 50) ? 2000 : 1900;
> $OldDate = $Year . $Month . $Day;
> $Now = strftime("%Y%m%d");
>
> if ($OldDate < $Now) {
>
> # --> $CompareTo is before Now.
>
> } elsif ($OldDate > $Now) {
>
> # --> $CompareTo is after Now.
>
> } else {
>
> # --> $CompareTo is today!
>
> }
>
> -- WARNING: The above code is untested and off the top of my head.
>
> --
> Warmest Regards...
> __________________________________________________________________
> Jeff Carnahan                                        Networq, Inc.
> http://www.networq.com/                      jcarnahan@networq.com
> __________________________________________________________________
>
>
>
> > -----Original Message-----
> > From: owner-minivend-users@minivend.com
> > [mailto:owner-minivend-users@minivend.com]On Behalf Of Cameron B. Prince
> > Sent: Monday, June 12, 2000 07:08 PM
> > To: minivend-users@minivend.com
> > Subject: [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
> >
>
> -
> 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
>

-
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: